Get Sequence Messages

Hello everyone,

I’m writing to ask for your help on a specific subject. I’m developing a script to get the list of SequenceMessages for each scenario in a capability. However, using the get_owned_message() function returns an empty list, and I can’t understand this behavior. Could someone please explain or give me a hint?

My simple code :
Capabilities_liste = se.get_all_contents_by_type(Capability)

print(“***********************”)
print(Capabilities_liste[0].get_name())
print(“----------------”)
involved_scenario = Capabilities_liste[0].get_owned_scenarios()

for scenario in involved_scenario:
print(scenario.get_name())
print(scenario.get_owned_messages())
print(“------------”)

The list is not empty but the the implementation of JavaList doesn’t provide the str method which is misleading. I opened an issue on Python4Capella:

print('***********************')
print(Capabilities_liste[0].get_name())
print('----------------')
involved_scenario = Capabilities_liste[0].get_owned_scenarios()

for scenario in involved_scenario:
    print(scenario.get_name())
    for message in scenario.get_owned_messages():
        print('    ', message.get_name())
    print('------------')

Thanks for your feedback.

I have another small question concerning the SequenceMessage class. I want to retrieve the Invoked_exchange attribute from the SequenceMessage, but this generates an error indicating that the getInvokedExchange() function on the Java object doesn’t exist. Indeed, after checking Capella Java API, I couldn’t find this function (as shown in the attachment). However, the function seems to be used in the body of the get_Invoked_exchange() method of the SequenceMessage class(in the attachment).

Could you please provide me with a solution to this blockage?

As a workaround, you can use the query from the semantic browser:

for exchange in capella_query_by_name(mySequenceMessage, 'Invoked Interaction', AbstractExchange):
    print(type(exchange), exchange.get_name())

I also opened an issue: