labs4capella / python4capella

Python for Capella
Eclipse Public License 2.0
52 stars 10 forks source link

CapellaModel.get_all_diagrams() doesn't work. #186

Closed ylussaud closed 11 months ago

ylussaud commented 12 months ago

The Sirius module return a non empty list but the Python loop doesn't iterate over it. To fix this we can use the following code:

    def get_all_diagrams(self) -> List[Diagram]:
        """
        Returns: Diagram[*]
        """
        return JavaList(Sirius.get_all_diagrams(self.session), Diagram)
EAly commented 11 months ago

Hi @ylussaud I tried to substitute the body of the get_all_diagrams() method in the simplified_api/capella.py file with the code you provided, but I still get an empty list.

ylussaud commented 11 months ago

Hi @EAly

I used the following script on the IFE example and it works with the above patch:

# include needed for the Capella modeller API
include('workspace://Python4Capella/simplified_api/capella.py')
if False:
    from simplified_api.capella import *

aird_path = '/In-Flight Entertainment System/In-Flight Entertainment System.aird'
model = CapellaModel()
model.open(aird_path)

diagrams = model.get_all_diagrams()
for diagram in diagrams:
    print(diagram.get_name())

I'm using Capella 6.1.0 under Linux with Python 3.7.17. I can test with other version of Capella or Python if needed.

EAly commented 11 months ago

Hi @ylussaud ,

Thanks for your reply, I tried the script on the IFE example as well as on another project I'm working on and I get an empty list in both cases. I'm using Capella 6.10 under macOs 13.5.1 with python 3.11.4

Thanks again for your help

ylussaud commented 11 months ago

I tried with Python 3.11.5 and it works... Not sure what is going wrong here.

EAly commented 11 months ago

Thanks @ylussaud , it worked after I reloaded the Python4Capella project.