Get the related diagram of an element

how to get all related diagrams of a capella elements?
image
how can i study m2doc sementic relationships by myself so that I can ask less basic questions? Thank you so much^-^

also how to get the contained elements of a diagram

M2Doc relies on AQL for model navigation. And AQL use the metamodel (EPackage) to find EStructuralFeature to navigate. It basically addapt to metamodels imported in its environment.

For Capella, you can check its metamodels available here. You can use Ecore Tools to create a graphical representation.

Capella is build on top of Sirius, it provides graphical representations. Sirius also have its own metamodels:

You can also use the reflective API to get the EClass of an element and list all its available features:

element.eClass().eAllStructuralFeatures

AQL provide a set of services, see the AQL documentation. M2Doc also provide its own services.

For semantic (from the point of view of Sirius) references you could use one of the services eInvers() but the corssreferencer installed by Sirius filter out Sirius graphical references. So in this case you need to get all instances of DRepresentationDescriptor:

viewpoint::DRepresentationDescriptor.allInstances()->select(d | d.target = capellaElement).representation.name

You will need to import Sirius nsURIs to your template using the template property wizard.

This one is not basic :wink:

1 Like

Thank you, this could help me locate diagram.
how to display them in the generated file? asimage() doesn’t seem to work

You need to get the DRepresentation and call the asImage() service:

viewpoint::DRepresentationDescriptor.allInstances()->select(d | d.target = capellaElement).representation.asImage()

Hello together,

I have been following this discussion and have a question related to this topic.

My aim is to access the elements displayed in a graph and display them in M2Doc. For example, I have a graph that shows several components and functional chains. I want to start from this graph, access the functional chains displayed in the graph and then get the referenced requirements of the functional chains for example.

I am able to access the graph as described above using

viewpoint::DRepresentationDescriptor.allInstances()->select(a|a.name=‘NameOfGraph’).

Adding .eClass().eAllStructuralFeatures only gives me features like documentation/description, however, I was not able to express things like the components, functional chains…

Is there a way to get the functional chains and then access the requirements associated with those functional chains using the graph as a starting point?

Thanks for your help:)

You need to access the representation then its graphical elements (check if the graphical element is visible) and then their semantic element (CapellaElement):

viewpoint::DRepresentationDescriptor.allInstances()->select(a|a.name=‘NameOfGraph’).representation.representationElements->select(re | if re.oclIsKindOf(diagram::DDiagramElement) then re.visible else true endif).target->collect(e| if e.oclIsKindOf(cs::Part) then e.type else e endif)

I also included the needed expression to get the type of a Part (for instance its component).

1 Like

Thank you, this is what I was looking for! :smiley: