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.


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 ?


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.

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