Extracting Exchange Items via Python4Capella


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.

Thank you a lot in advance!

Greetings, Samet.

Hi Samet,

You can use the ExchangeItem Python class to list exchange items. A basic script that list all exchange items in a Capella model:

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()

# gets the SystemEngineering and print its name
se = model.get_system_engineering()

for exchange_item in se.get_all_contents_by_type(ExchangeItem):

Hi Yvan,

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?

Thanks in Advance
Greetings Samet

For the simple cases you can use the following:

for exchange_item in se.get_all_contents_by_type(ExchangeItem):
    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.

1 Like

Hi Yvan,

thank you a lot!

That was exactly what I was looking for.
It worked and this fulfills my requirements:



1 Like