Issue in Python4Capella with Capella 6.0.0

I am testing the new CAPELLA 6.0.0 version. I have an issue with Python4Capella using the script

This error does’nt happen with CAPELLA 5.2. did I do something wrong?


You did nothing wrong, Your model contains Requirement and Attribute for those requirements. The script tha list all LogicalFunction use get_all_contents_by_type(LogicalFunction) this walks all the model and try to create Python object. At some point we try to create an Attribute but the class is defined in the requirement module.

You can replace the line:

        res = Attribute


        res = getattr(sys.modules["__main__"], "Attribute")

This will only create Attribute if you included the requirement module in your script.

EDIT: I updated the release, you can resinstall to have this fix. I missed this bug before releasing. Thank you for the feedback.

I downloaded your latest release. It works indeed.
an other suggestion: I have had to add “include(‘workspace://Python4Capella/simplified_api/’)” in many scripts in the sample_scripts folder. It could be fine to also update the Python4Capella project.
see you soon in the forum !

1 Like

Following this thread I have uptated Capella to the 6.0 release and I found that the scripts written before are not working anymore. To give an example I report this test script that I have used to extract Property Values on Logical components, before updating this script used to work as expected but now it doesn’t print anything, I do not know if I am doing something wrong or the script is wrong or I have created property values in the wrong way now, anyway I was hoping for some help.
Thank you.

The result of the script is a completely empty console, so there is no need to send also a screenshot of it, and the script doesn’t give errors, this is the same for all the scripts with which I try to access and print all kinds of property values, requirements and basic mass viewpoint information. In version 5.2 the result was coherent with the model created and property values were printed

Can you add a print statement at the beginning of your script just to make sure the script is executed ?

I created a Capella 6.0.0 environment with PVMT installed from the update site on the download page and Python4Capella 1.1.0.

And it seems to work:

Can you open the error log view and tell me if there is any error in it related to the script ?


I added multiple print statements in the code to make sure that it is working and it seems that is running entirely. I am using Capella 6.0 and Python4Capella 1.1.0 like you and the PVMT was installed with the update site as well.
Here it is what the error log says:
The method name “zip” from the module “__EASE_MOD_org_eclipse_ease_modules_platform_ResourcesModule” can not be wrapped because it’s name is reserved

This error can be ignored. And your script is executed. From the output you gave I think no LogicalComponent is found otherwise we would see them. But in the project explorer I can see some LogicalComponent.

Can you try the following code and see if it output something:

# include needed for the Capella modeller API
if False:
    from simplified_api.capella import *
# include needed for the pvmt API
if False:
    from simplified_api.pvmt import *

model = CapellaModel()"/TMS_test_2/TMS_test_2.aird")
se = model.get_system_engineering()
tested = None
for sf in se.get_all_contents_by_type(LogicalComponent):
    #: :type sf: LogicalComponent
    if sf.get_name() == 'TMS':
        tested = sf


for pvName in PVMT.get_p_v_names(tested):
    print(pvName,PVMT.get_p_v_value(tested, pvName))

Maybe you can also check that the property values are displayed under the TMS LogicalComponent in the project explorer.

I am sorry but also this script doesn’t work, here it is the error displayed in the console:

I do not know what these errors concern
Property values are displayed correctly in the project explorer as you can see
I do not know why but it seems that the script that I first sent to you “sees” the TMS_test_2 model but “doesn’t see” the logical component in it

tested is None but you have a LogicalComponent named TMS… Try to remove the filter on LogicalComponent. Replace:




But I don’t see what is happening here… You should try to print your variables see where things are going wrong.