Hi All,

I wonder if you can help me with an addition to the simplified capella api?

Ordinarily when attempting to set source ports onto an exchange (Functional or Component), we can use the following:

def set_source_port(self, value):
    return self.get_java_object().setSource(value.get_java_object())

I added the above to the component exchange class after using the sirius interpreter to check if that was the correct Java function. It was and it worked for component exchanges!

For Physical Links and setting physical source ports, the interpreter suggests that instead of ‘aql:self.source’ we use, ‘aql:self.sourcePhysicalPort’ to identify the source port.
As a result of this I’ve added the below function under the Physical Link class in the simplified capella api:

 def set_source_port(self, value):
     return self.get_java_object().setSourcePhysicalPort(value.get_java_object())

This does not work, and it’s the same for ‘setTargetPhysicalPort’. Can anyone help me with why this wouldn’t work or ways to fix it?

For reference, this is the error message (which indicates that it may not be included in a file that I cannot access):

org.eclipse.ease.ScriptExecutionException: Traceback (most recent call last):
File “L/Python4Capella/WIP/Exchange Link Accelerator/Road Map/EA Import Development/”, line 133, in
File “L/Python4Capella/simplified_api/”, line 2598, in set_source_port
File “C:\Users\acook\Capella Suite\Capella 1.4.2\Capella 1.4.2\Capella 1.4.2\eclipse\plugins\py4j-python_0.10.9.3-bnd-2odeag\src\py4j\”, line 1322, in call
answer, self.gateway_client, self.target_id,
File “C:\Users\acook\Capella Suite\Capella 1.4.2\Capella 1.4.2\Capella 1.4.2\eclipse\plugins\py4j-python_0.10.9.3-bnd-2odeag\src\py4j\”, line 332, in get_return_value
format(target_id, “.”, name, value))
py4j.protocol.Py4JError: An error occurred while calling o1096.setSourcePhysicalPort. Trace:
py4j.Py4JException: Method setSourcePhysicalPort([class]) does not exist
at py4j.reflection.ReflectionEngine.getMethod(
at py4j.reflection.ReflectionEngine.getMethod(
at py4j.Gateway.invoke(
at py4j.commands.AbstractCommand.invokeMethod(
at py4j.commands.CallCommand.execute(
at py4j.ClientServerConnection.sendCommand(
at py4j.CallbackClient.sendCommand(
at py4j.CallbackClient.sendCommand(
at py4j.reflection.PythonProxyHandler.invoke(
at com.sun.proxy.$Proxy30.executeScript(Unknown Source)
at org.eclipse.ease.lang.python.py4j.internal.Py4jScriptEngine.internalExecute(
at org.eclipse.ease.lang.python.py4j.internal.Py4jScriptEngine.execute(
at org.eclipse.ease.AbstractScriptEngine.inject(

The trace suggest you called set_source_port() on a PhysicalPort instead of a PhysicalLink:

Method setSourcePhysicalPort([class]) does not exist

You should double check the type of the element you are calling the method from. Maybe you passed a Java PhysicalPort to the constructor of the Python class PhysicalLink ?


Hi Yvan,

Thanks for your speedy response!
You make a good point but I’m not sure how I’m calling a PhysicalPort. In the section of my script that is calling these functions I call the PhysicalLink() class here:

#prepare the link to be added
PL = PhysicalLink()

I’m attempting to assign the source (PPS) and target (PPT) target port to PL before I add it to the model. Any idea why it would then be trying the function/method for a port?

By looking at the Java API you should be able to use:


Source and target ports getters are derived from the links ends EReference.

1 Like

Fantastic thank you so much!

I tried to use ‘setLinkEnds’ but that didn’t work and I then ignored it.

This works perfectly, I massively appreciate your help Yvan!

1 Like