you can use the method get_owned_exchange_items() :
(bad) example code:
se = model.get_system_engineering()
data = se.get_logical_architecture().get_interface_pkg()
...
for item in my_interfaces[(source_name,target_name)]:
itf_item = ExchangeItem()
itf_item.set_name(item)
exists = False
for exchange_item in data.get_owned_exchange_items():
if exchange_item.get_name() == item:
itf_item = exchange_item
exists = True
if not exists:
data.get_owned_exchange_items().add(itf_item)
Yes you should use the get_owned_exchange_items() method. To be more precise, you are calling a Java method on a Python object. That’s why Python complains about the method that doesn’t exist. To navigate between the Java and Python world, you can have a look at the tips and tricks from the documentation.
OK, I think I missed something or it might be dependent on the Python version… but in any case you can ignore it.
Yes you need to use the Java class qualified name. You can get it by selecting the element and using the Sirius interpreter view with the following AQL expression:
yes, that is what I tried # popup : enableFor(org.polarsys.capella.core.data.cs.InterfacePkg)
but the popup menue item still shows up on every Capella Item.
Function, Capability, even on an aird where no other of the sample scripts popups are shown.
The error-message may be triggered by include line in my script…
# include needed for the Capella modeller API
include('workspace://Python4Capella/simplified_api/capella.py')
if False:
from simplified_api.capella import *
I know EASE magic header can be affected by the order of the lines in it (check the order against this script for instance). You might also want to check if you have other script with the same header that apply on other types of object (after a copy for instance).
I have inserted an empty line with “#” and a comment line “# This Script…“ after the popup - now it ist working…
That is really a magic header ;-> Thx"!
# name : Import ExchangeItems from Excel
# image : platform:/plugin/org.polarsys.capella.core.sirius.analysis/icons/full/obj16/ExchangeItemFlow.gif
# script-type : Python
# description : Imports ExchangeItems from Excel ('Import_Informations/Structure_Informations.xlsx')
# popup : enableFor(org.polarsys.capella.core.data.cs.InterfacePkg)
#
# This Script ...