Failure of some Python4Capella scripts

Testing some of the sample scripts provided with Python4Capella, I noted that some of them have bugs ?!?.

In the error dump log in the console, there is always the same kind of error, coming from the “” and “” modules as indicated below for the test of “”

////////////// error log ///////////////////////////////////////////////////////////////////////////////////////////////
starting export of model In-Flight Entertainment System
org.eclipse.ease.ScriptExecutionException: Traceback (most recent call last):
File “workspace://sample_scripts/”, line 81, in
File “workspace://Python4Capella/simplified_api/”, line 239, in get_all_contents_by_type
self.except_data = except_data
File “workspace://Python4Capella/java_api/”, line 35, in next
File “workspace://Python4Capella/java_api/”, line 27, in next
from py4j.java_collections import ListConverter as _pyease_ListConverter
File “workspace://Python4Capella/simplified_api/”, line 164, in get_class
AttributeError: module ‘main’ has no attribute ‘Attribute’

This is a bug that have been fixed:

You can check the linked discussion or the commit to patch EObject.get_class() in your file.

I have read the discussion … but it is not clear that the bug has been solved ?!?

I am using :

  • Capella 6.0.0
  • Python4Capella 1.1.0
  • Requirement VP 0.13.0
  • PVMT 60.6.0
  • DiagramStyler 60.3.1
  • System to subsystem 1.6.0
  • Capella Filtering 1.6.0
  • HTLM generation 6.0.0

I have the bug for (non exhaustive list) :

  • Export_description_of_elements _with_html format_and_as_plain

Are OK (non exhaustive list) :


It should be fixed in the 1.1.0… I just checked the update site on the release page for version 1.1.0 and line 164 of is:

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

Did you reimporte the Python4Capella project after updating ? This is needed to have the last version of Python scripts. You can download the update site from the release page if needed. You can also patch the line but other fixes will be missing…

EDIT: I might have respined this release shortly after the initial release. That might explain the difference in your version.

I have re dowloaded
57.8 MB
Sep 26, 2022

followed all steps as described here : GitHub - labs4capella/python4capella: Python for Capella

and in, i have on line 164

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

but I still get the same errors … some scripts are correct but the others not

OK… The bug is still here somehow. You add an import to the module declaring Attribute:

# include needed for the requirement API
if False:
    from simplified_api.requirement import *