Hello python4capella community! I’m trying to generate a physical link between two physical components, but every time I try it I get several errors. There are many predesigned scripts but none of them create physical links between, two PC can you give me a hand? Thanks in advance. I have only two components with one physical port each (PP 1 and PP 1_1), I try the following code:
include('workspace://Python4Capella/simplified_api/capella.py')
if False:
from simplified_api.capella import *
include('workspace://Python4Capella/utilities/CapellaPlatform.py')
if False:
from utilities.CapellaPlatform import *
from openpyxl import *
aird_path = "/TEST/TEST.aird"
model = CapellaModel()
model.open(aird_path)
se = model.get_system_engineering()
pc_pkg = se.get_physical_architecture().get_physical_system()
# start a transaction to modify the Capella model
model.start_transaction()
try:
PL = PhysicalLink()
PL.set_name("Cable1")
for elem in se.get_all_contents_by_type(PhysicalPort):
print(elem.get_name())
if elem.get_name() == str("PP 1"):
PL.get_java_object().getLinkEnds().add(elem.get_java_object())
if elem.get_name() == str("PP 1_1"):
PL.get_java_object().getLinkEnds().add(elem.get_java_object())
PL.get_java_object().getOwnedFeatures().add(PL.get_java_object())
org.polarsys.capella.core.model.helpers.CapellaElementExt.creationService(PL.get_java_object())
except:
# if something went wrong we rollback the transaction
model.rollback_transaction()
raise
else:
# if everything is ok we commit the transaction
model.commit_transaction()
# save the Capella model
model.save()
I get the following error that I cannot understand:
org.eclipse.ease.ScriptExecutionException: Traceback (most recent call last):
File "workspace://Python4Capella/CODE/TESTS.py", line 36, in <module>
from six import integer_types as _pyease_integer_types
File "C:\Users\\\PROGRAMS\CAPELLA\CAPELLA_PROGRAM_FILES\..\..\..\..\..\..\Application Data\Orchestra\Capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_gateway.py", line 1322, in __call__
answer, self.gateway_client, self.target_id, self.name)
File "C:\Users\capella\..\..\..\..\..\..\Application Data\Orchestra\Capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\protocol.py", line 332, in get_return_value
format(target_id, ".", name, value))
py4j.protocol.Py4JError: An error occurred while calling o196.getOwnedFeatures. Trace:
py4j.Py4JException: Method getOwnedFeatures([]) does not exist
at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:326)
at py4j.Gateway.invoke(Gateway.java:274)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.ClientServerConnection.sendCommand(ClientServerConnection.java:244)
at py4j.CallbackClient.sendCommand(CallbackClient.java:384)
at py4j.CallbackClient.sendCommand(CallbackClient.java:356)
at py4j.reflection.PythonProxyHandler.invoke(PythonProxyHandler.java:106)
at com.sun.proxy.$Proxy71.executeScript(Unknown Source)
at org.eclipse.ease.lang.python.py4j.internal.Py4jScriptEngine.internalExecute(Py4jScriptEngine.java:240)
at org.eclipse.ease.lang.python.py4j.internal.Py4jScriptEngine.execute(Py4jScriptEngine.java:227)
at org.eclipse.ease.AbstractScriptEngine.inject(AbstractScriptEngine.java:189)
at org.eclipse.ease.AbstractScriptEngine.run(AbstractScriptEngine.java:242)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
It says that getOwnedFeatures() does not exist, I really dont know how to add the physical link in a proper way, how can I solve this? Thanks in advance.