Python4Capella for beginers (how to start with it?)

Hello,
I’m not familiar with Python4Capella and with Python language itself.
Does documents / training are available to teach how to start with Python4Capella?
Thanks

Hi Fabien,

For the Python part you can start with any tutorial available only I guess:

For the Python for Capella part, you can start by having a look at the project page and the installation section. After installation you will have a project with sample scripts. You can try to run some of them to get a starting point.
You can also have a look at the documentation, the documentation is also available in the Eclipse help menu. I also suggest you read the tips and tricks page for trouble shooting.

For more context on the Capella API you can check the metamodels (*.ecore files) and the corresponding Java code.

Later you might also have a look at EMF and Sirius.

And if you have some questions in the process feel free to ask them. I’ll be in holidays for a few week so responses might not be as fast as this one.

Hello Yvan,

I’m a bit late in thanking you for all that detailed information.
By following it closely, I was able to install the add-on and carry out some development work.

I also used the two files—filtering_header.py and filtering.py—that you provided here: Filtering Add-on and Python4Capella

Using them, I built three utilities:

  1. An utility to import a repository of FilteringCriterionPkg and FilteringCriterion elements into a Filtering Model, and to initialize the Filtering Results (including FilteringResultPkg and FilteringResult).
  2. An utility to assign a FilteringCriterion to a large number of modeled objects.
  3. An utility to retrieve progress statuses (e.g., draft, reviewed_ok) and create a dynamic FilteringCriterion:
  • Creation of FilteringCriterion elements (e.g., draft, reviewed_ok).
  • Assignment of the FilteringCriterion to objects whose progress status matches that of the FilteringCriterion.

Best regards

1 Like

Good to hear it worked out. On the third utility, one thing worth planning for is that an object’s progress status can change after the criterion has been assigned, so the stored link goes stale. A small reconciliation pass that walks the model and re-assigns based on current status (or removes assignments that no longer match) keeps the filtering results consistent. The alternative is to evaluate the criterion at query time in the filtering script rather than persisting it, which avoids the staleness but costs more per run. Which of the two fits your workflow better probably depends on how often statuses change.