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 “capella.py” and “JAVA_API.py” modules as indicated below for the test of “Export_SF_and_FE_to_xlsx.py”
////////////// error log ///////////////////////////////////////////////////////////////////////////////////////////////
starting export of model In-Flight Entertainment System
org.eclipse.ease.ScriptExecutionException: Traceback (most recent call last):
File “workspace://sample_scripts/Export_SF_and_FE_to_xlsx.py”, line 81, in
set_types=set):
File “workspace://Python4Capella/simplified_api/capella.py”, line 239, in get_all_contents_by_type
self.except_data = except_data
File “workspace://Python4Capella/java_api/Java_API.py”, line 35, in next
try:
File “workspace://Python4Capella/java_api/Java_API.py”, line 27, in next
from py4j.java_collections import ListConverter as _pyease_ListConverter
File “workspace://Python4Capella/simplified_api/capella.py”, line 164, in get_class
‘’’
AttributeError: module ‘main’ has no attribute ‘Attribute’
/////////////////////////////////////////////////////////////////////////////////////////////////////////
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 capella.py 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.
OK… The bug is still here somehow. You add an import to the module declaring Attribute:
# include needed for the requirement API
include('workspace://Python4Capella/simplified_api/requirement.py')
if False:
from simplified_api.requirement import *