How to set a realized Logical Component in a Physical Component with Py4C

Hi,

How to set a realized Logical Component in a Physical Component with Py4C?

Thanks,

d

I’m not sure why this don’t work. But it can be a starting point:

lc = LogicalComponent()
pc = PhysicalComponent()

cr = create_e_object("http://www.polarsys.org/capella/core/cs/" + capella_version(), "ComponentRealization")

cr.setSourceElement(pc.get_java_object())
cr.setTargetElement(lc.get_java_object())

pc.get_java_object().getOwnedComponentRealizations().add(cr)

Maybe an other relation is needed or the fact that my objects aren’t connected to a Capella model is the cause of the issue…

Hello Yvan,

Many thanks for this script, it works and I succeeded in connecting more than 300 physical components to their realized logical component in 5 minutes even though I was afraid I had to do it manually !!!

see you

d

2 Likes