Diagram related to an element in M2DOC

Hello everyone,

Is it possible in M2Doc to list all the diagrams linked to a model element (such as in the Semantic Browser) ? I do not find a way to do it simply.

Regards,

1 Like

From a DRepresentation rep and the model element self you can do this:
rep.getDescriptor().oclAsType(viewpoint::DRepresentationDescriptor).eContainer(viewpoint::DAnalysis).eAllContents(viewpoint::DRepresentationDescriptor).representation->select(r | r.eAllContents(viewpoint::DRepresentationElement)->includes(self))

It list all DRepresentation available, then select select representations where one of the DRepresentationElement is representing (the target feature) the given self element.

Hello Yvan,

I tried your solution, however I face a little issue while implementing it (I attached the validation file to this message)

So I tried to edit the template services ‘by hand’ with the ‘Edit Template property menu’. I added Capella and Sirius packages. However, a new error appeared:

I am using Capella 1.4.0 and M2Doc 3.0. Has something like that already happened to anyone ?

You should remove the nsURI from the template using the template properties wizard. Or you can replace it with the nsURI corresponding to your installed version.

Hello Yvan, thanks for your help.

When I remove the nsURI sirius/tree/1.1.0, the first error appears again (could not find the get descriptor service).

Where can I find the nURI / services corresponding to my version ?

Rgds,

The service getDescriptor() doesn’t exist in M2Doc 3.0.0. You can try with something like:
rep.oclAsType(viewpoint::DRepresentation).precedingSiblings(viewpoint::DAnalysis).eAllContents(viewpoint::DRepresentationDescriptor).representation->select(r | (r.eAllContents(viewpoint::DRepresentationElement)->including( r )).target->includes(self))

I added the representation to the selection in case self is the root element of the representation. I also added a missing target. It should work.

1 Like

And it is working :slight_smile: Thank you very much Yvan, I hope it will help also other people.

Hello everyone,

Someone asked me a question about this topic, and I found a strange behavior.

The request Yvan detailed in this topic is roughly 'display all the diagrams in which a DRepresentationElement correspond to my element.

So, why in the template attached, that tries to list all the diagrams in which the Actor ‘Aircraft’ appears (in the IFE project), the SAB are not displayed?

LA_Complete.docx (19.7 KB) Template LA Complete.docx (23.2 KB)

Regards

I changed the request for to the following, maybe it will help:

diagram::DSemanticDiagram.allInstances()->select(d | d.representationElements->select(re | if re.oclIsKindOf(diagram::DDiagramElement) then re.visible else true endif)->including(d).target->includes(semanticElement)).name

Even if it should be equivalent. I’ll try to check it with the IFE project and the actor ‘Aircraft’.

Copyright © Eclipse Capella, the Eclipse Capella logo, Eclipse and the Eclipse logo are Trademarks of The Eclipse Foundation.