Exporting Diagrams from OA and SA

I am using capella 5.0 and try to figure out how to work with M2DOC.
I am able to extract all the descriptions from the Modellelements in the different Packages (Operational Analysis, System Analysis etc.) So far so good.
Now I want also to export my diagrams.
I started with [OCB] with:
{m:for ocb | self.eAllContents(oa::OperationalCapabilityPkg)}
{m:if cob.isRepresentationDescriptionName(‘Operational Capabilities Blank’)}
{m:ocb.asImageByRepresentationDescriptionName(‘Operational Capabilities Blank‘)}->first().setWidth(600)}

This works also fine
But when I now try to extract the Operational Architecture Blank on a similar way (using the EntityPkg), then I do not get any Image to my Wordfile. There are also no errors, it simple proceed the script, but does not extract the related image.

Similar on System Analysis or Logical Architecture. Some diagrams will be extracted, some not. But here it seems that only those diagrams will be extracted, that were not created by cloning diagrams.

any advices, or is there a different way to extract diagrams?
I am trying it a few days and it is very hard for me to understand the reference documentation on M2DOC.
I have some experiences in Word/Excel VBA and Javascript, so I am not a newbie on Wordscripts, but I am absolutely lost with AQL and M2DOC.

Thanks for helping and best regards

You can use the interpreter views to have content assist and a visualization of the result of your AQL queries:

I will use the self variable in the following queries but if you ate using the M2Doc interpreter view you will probably need to use the selection variable. Also note that the Sirius interpreter view doesn’t provide specific M2Doc services like the one you are trying to use here.
To use the asImageByRepresentationDescriptionName() service you need to know the name of the description for a diagram and also the kind of element the diagram use as root element. To find those information, you can select the background of the diagram and use the following queries:


And with the first query you will see that unfortunately the name displayed by Capella and the name of the diagram description is not the same. You should use:

'Operational Entity Blank'

A cloned diagram can be accessed the same way as an original diagram. Something that might be useful is to work with the diagram itself instead of the image directly by using the representationByDescriptionName() with the same parameters as the asImageByRepresentationDescriptionName() service. You can then do something like:


I hope it will help you work with M2Doc.

Hello Yvan,
Thank you for your quick response.
I changed the name for the Operational Architecture Blank into Operational Entity Blank.
It works as you suggested :-). Thanks a lot.
I tried the interpreter view, but had some troubles with the query. The interpreter gave me some errors back, as soon as I type "aql: ". Maybe I forgot something, I will check it tomorrow.
Also using the diagrams itself instead of images of the representations makes sense to me. I will try it and will come back, if there are any troubles.
For now: many thanks for your help
Best regards

If you are using the M2Doc interpreter view the “aql:” is not needed.

Sorry to come again with that thread,
Finally I tinkered a template that works fine for me. But now I have to face the challenge to display some not all) diagrams, that are related to a logical component. It is necessary because I had to split a Breakdown into several parts (better readability in the document). So I cloned the logical breakdown diagram and made several more handsome diagrams. The problem is that I am not able to address them by the using the (…)descriptionName() services, because they all have different names then the logical main component.

So I remembered that you mentioned a method to address the diagrams directly, instead of using the services. I used the interpreter to find the correct way to address the diagrams and tried to address them with self.eAllContents(viewpoint::DRepresentationDescriptor).
But when I put this into the template, I got an “empty collection” error.
My idea was to address the diagram to variable and then make a decision by if/elseif withe the structure you suggested (someDiagram.name). I guess I did not understand the way how “someDiagram” is addressed in M2DOC…

Ohh, I am using capella 5.0 with the respective M2DOC…

To retreive all DRepresentationDescriptor you can use:


But I’m not sure that’s what you need to do here. Based on your first sample code, you should do something like:

{m:for diagram | ocb.representationByDescriptionName(‘Operational Entity Blank‘)}

This should list all Operational Entity Blank diagrams for the element ocb. The Sirius interpreter don’t have access to specific M2Doc services and configuration. You need to try those AQL expressions inside your template or use the M2Doc interpreter view which is not available for Capella 5.0.0 I think.

Thanks a lot for the quick help, now it works :slight_smile:

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