labs4capella / python4capella

Python for Capella
Eclipse Public License 2.0
53 stars 10 forks source link

Set container of component port with python #221

Closed Nelson1905 closed 2 months ago

Nelson1905 commented 2 months ago

Hi,

I want to change container of this component port (the new container will be System Function B) with python4capella but I didn't fund functions to do that.

Do you know how to do that. image

ylussaud commented 2 months ago

You can Move the FunctionInputPort like this:

mySourceSystemFunction = ...
#change with your own FunctionInputPort here
myFunctionInputPort = mySourceSystemFunction.get_inputs().get(0)
myTargetSystemFunction = ...
myTargetSystemFunction.get_inputs().add(myFunctionInputPort)

Since an EObject can only be contained by one EObject it will move the FunctionInputPort. You will need to run this code in a transaction in order to modify your model.

Nelson1905 commented 2 months ago

Yes it work thanks you !!!