I noticed that the function called “export_as_image()” inside the diagram class was “KO”.
Any idea how to fix it?
Here it is:
def export_as_image(self, file_path):
Well, in fact, it works.
You can try with a model with diagrams in Physical Architecture Structure:
project_name = "C2M_TEST_01" # Change for your model
model = CapellaModel()
folder = CapellaPlatform.getFolder(CapellaPlatform.getProject(project_name), "images")
folder_path = CapellaPlatform.getAbsolutePath(folder)
for diagram in (model
print("Export diagram", diagram.get_name())
diagram.export_as_image(folder_path + "/" + diagram.get_name() + ".jpg")
I don’t know what this comment means.
However, this function is limited when compared to the one in diagram: default resolution, only jpg.
This comment is added to the specification Capella model by generated unit test, but in this case the generated test fails… but the method works. The API is then generated from the specification model.
Thanks a lot to both.
I have few questions:
For this function:
def get_diagrams(self, diagram_type):
res = 
descriptors = Sirius.get_diagrams(self.session, diagram_type)
for descriptor in descriptors:
What type of “diagram_type” are we talking about?
I can simply write A=CapellaModel.get_diagrams(LAB)?
Or is it A=CapellaModel.get_diagrams(“LAB”)
Or: A=CapellaModel.get_diagrams(Logical Architecture Blank)
Or: A=CapellaModel.get_diagrams(“Logical Architecture Blank”)
I was wondering what is exactly a “diagram type”, is it a “string”?
Now question about the rest of the functions:
- We have (get_owned_diagrams()), i tried this on a Logical Component Package, and it worked fine.
- What about (def get_representing_diagrams(self)) what differntiate it from the rest?
- What does (def get_element_of_interest_for_diagrams(self): ) do compared to others?
- Same for (def get_contextual_element_for_diagrams(self): ) ?
It’s the name of the representation description, for instance “Logical Architecture Blank”. The implementation is available here. And it will return all LAB diagrams from the given Session.
- get_owned_diagrams() will return all diagrams defined on the given object. The object is represented by the background of a diagram for instance.
- get_representing_diagrams() will return all representations where the given element appears. At least one DRepresentationElement is visible on the representation for this element.
- get_element_of_interest_for_diagrams() is a concept defined by Capella. It returns what is returned by the “Element of Interest for Diagram” query, It is shown in the contextual explorer. From the Capella documentation: " The Elements of Interest property allows to associate a Diagram with an arbitrary list of model elements that are of special interest to the diagram. The Semantic Browser view displays the relation between a Diagram and its Elements of Interest.".
- get_contextual_element_for_diagrams() its a concept defined by Capella. it call the org.polarsys.capella.core.semantic.queries.sirius.annotation.eoi.RepresentationToContextualElement query. In the Capella documentation there is a section “Diagram Concepts” they are some explanations.