Capella MBSE Python (capellambse library)

I am trying out the declarative modelling by following the py - capellambse documentation (Declarative modelling - py-capellambse documentation). But the diagrams are not really added in capella workspace. For example, the program in the screenshot just adds the functions and the exchanges. But I also want them in a diagram in logical architecture or any other layer. Can someone suggest something for this?

I think the program does what it is supposed to do, ie created Capella semantic elements. I don’t think you will be able to create diagrams and put elements in it with the py-capellambse library. This library has minor dependencies towards the Capella workbench, ie no dependency towards the graphical part. It has its pros and cons, but creating Capella diagrams with it won’t be an option I think.

You may want to look into Python4Capella, which is completely dependant to the Capella workbench (again, pros and cons), but there you can manipulate graphical elements. Nevertheless, there is not yet a “simplified Python API” that enables you to manipulate those graphical elements easily, this may come in the next months, but right now creating new diagrams and adding elements to them is not going to be easy. There are a few thread in this diagram where people have used Python4Capella to change some graphical aspects in some diagrams (changing a color of an edge…).
One option here if you want to have faster results may be to contact Obeo.

I hope this helps.
Stephane

Thank you for your reply. So, currently with py-capellambse library it is not possible to create diagrams and add elements to it. But as capella supports scripting, can I update the .aird with py-capellambse library to include diagrams in it? Is that possible? If yes, can you elaborate?

Thanks,
Tirth

I don’t know very well py-capellambse, but generally speaking it is very unlikely you’re going to succeed in doing so. The .aird file stores complex graphical information in a complicated way as it graphical modeling in Capella rely on a series of layered frameworks that manipulates it (SWT/Draw2D/GEF/GMF/Sirius…), so recreating these behaviors without using these frameworks is going to be challeging I think.

Thanks for the valuable input. Does capella or any other add-in support JSON file for creation of diagrams? I highly doubt that it does, but I am not sure.

Not to my knowledge.