currently I’am searching for a opportunity to extract linked exchange items via Python4capella.
In the first step i created a CDB diagram, convert it into a library and linked it in my model with the library function. Then i have linked the exchange items with the models functional exchanges.
In the second step, I would like to extract the exchange items to a excel sheet.
Is there a possibility for such an approach with Python4capella?
Currently, i can only extract functional exchanges and I couldn’t find any information about extracting exchange items.
You can use the ExchangeItem Python class to list exchange items. A basic script that list all exchange items in a Capella model:
include('workspace://Python4Capella/simplified_api/capella.py')
if False:
from simplified_api.capella import *
# aird_path = '/IA/IA.aird'
aird_path = '/In-Flight Entertainment System/In-Flight Entertainment System.aird'
model = CapellaModel()
model.open(aird_path)
# gets the SystemEngineering and print its name
se = model.get_system_engineering()
for exchange_item in se.get_all_contents_by_type(ExchangeItem):
print(exchange_item.get_name())
Thank you very much, it worked.
Now the names of the exchange items are printed in the console.
Is there also a possibility to display the values of the exchange items or e.g. the linked physical quantities e.g. min, max, default values with the units?
for exchange_item in se.get_all_contents_by_type(ExchangeItem):
print(exchange_item.get_name())
for element in exchange_item.get_owned_elements():
print(' - ', element.get_name(), element.get_java_object().getType().getName(), element.get_java_object().getOwnedMinCard().getValue(), element.get_java_object().getOwnedMaxCard().getValue())
But for more complex cardinalities you will need to check the type to extract the needed value.