Adding a PhysicalPort to a PhysicalComponent

Hi there,

I am trying to add a PhysicalPort to a PhysicalComponent via P4C.

After some reading in the forum I get the impression that this is only possible via an ComponentExchange, but in Capella itself it seems no problem to just having a PhysicalPort attached to a PhysicalComponent.

I am still trying to understand how the PhysicalPort is ‘assigned’ to the PhysicalComponent.

Maybe you can help me with this. What I am trying to do is to add PhysicalPorts to PhysicalComponents marked with an PVMT attribute based on information from an external library without yet making any connections.

Thank you in advance.

Kind regards

Janis

You need to use a physical node and use the Java API to set its owned features:

myNode = Node() # or retrieve a Node from the model
myPhysicalPort = PhysicalPort() # or retreive a PhysicalPort from the model
myNode.get_java_object().getOwnedFeatures().add(myPhysicalPort.get_java_object())

Hi Yvan,

thank you a lot.

I missed the getOwnedFeatures() part.

Best regards

Janis

1 Like