Hello, everyone. Is it possible to get the logical components from a component exchange.
In fact, I can already list all the component exchanges of the Logical Architecture diagram using the following script. For example, component exchanges 1, 2, and 3 in Figure 1.
diagram_name = “xxx"
for diag in JavaList(org.eclipse.sirius.business.api.dialect.DialectManager.INSTANCE.getAllRepresentationDescriptors(model.session),Diagram):
if diag.get_name() == diagram_name:
for comp in diag.get_represented_elements():
if isinstance(subcom, ComponentExchange):
print(subcom.get_name())
However, an error (Figure 3) occurred when I attempted to list both component exchanges and logical components (For example, Component Exchange 2; Logical Component B; Logical Component A in Figure 2)using the script described below.
It is worth mentioning that when we obtained the CommunicationMean corresponding to the Operational Entity before, the following script was feasible, but it is not applicable to the current problem.
Note that there was a bug in the implermentation of JavaList that always shows the list as empty (see this issue for more details). The bug has been fixed in version 1.3.0.
Thank you for your answer. I found that I am still using Python4Capella version 1.2.0. I will upgrade to the version you suggested and try again.
Thanks again!
Thank you very much for your previous reply. Recently, I installed Python4Capella version 1.3.0 and retested your suggestion. The code and program used are shown below.
aird_path = ‘/Test/Test.aird’
model = CapellaModel()
model.open(aird_path)
se = model.get_system_engineering()
diagram_name = “[LAB] Structure”
for diag in JavaList(org.eclipse.sirius.business.api.dialect.DialectManager.INSTANCE.getAllRepresentationDescriptors(model.session),Diagram):
if diag.get_name() == diagram_name:
for subcom in diag.get_represented_elements():
if isinstance(subcom, ComponentExchange):
InterRel=subcom.get_name()
A=str(subcom.get_connected_components()[0])
B=str(subcom.get_connected_components()[1])
print(InterRel + “;” + A +“;” + B)
The results obtained are as follows (as shown in Figure 1):
C 1;<main.LogicalComponent object at 0x000001F576C4CD90>;<main.LogicalComponent object at 0x000001F57765BE10>
C 2;<main.LogicalComponent object at 0x000001F57765A5D0>;<main.LogicalComponent object at 0x000001F57765AF10>
C 3;<main.LogicalComponent object at 0x000001F57765AD50>;<main.LogicalComponent object at 0x000001F577659110>
But the actual result I want is like this.
C 1;LC 1;LC 3
C 2;LC 2;LC 3
C 3;LC 4;LC1
May I ask where the problem lies? I suspect that the names of logical elements are not stored in this JavaList, but I don’t know how to do it.
I have attached the test model and diagram. Thank you again for your enthusiastic response. Test.zip (10.4 KB)
in your example A and B are LogicalComponent and when you call str() on them it display technical Python information about those objects. If you want to display their names you can use: