display diagrams

I have been trying to function m2doc since days just to display the diagrams (system architecture, etc).
Too complex for systems engineers who cannot afford loosing time for creating a word document! There are no clear documentation…
I ended up with this piece of code attached.
I have no errors, but no image is displayed, only the logical elements names are there.
What should I do?
Thank you.

try display diagrams.jpg
try display diagrams.jpg

Did you follow the
Capella tutorial ?
With that you should be able to generate a document with diagrams in a matter of minutes.
You can double check the name of available representations name with
availableRepresentations(). You can use the names listed in the table with other services such as
asImageByRepresentationDescriptionName() or
I will be glad to improve the documentation if you have any constructive remakes.

To complete Yvan’s answer, there is also an extremly usefull MS Word add-in to edit your templates. It will provides you with autocompletion, expression evaluation, etc.
All details are available in the dedicated section here:


First, you have to add these additional nsURI packages to your m2Doc template. To do so, right click on your m2doc template (under Capella) and select “Edit Template properties” amd then go to the nsURI(expert) tab, click on “add” and search for *sirius.
Then please find attached an image of a m2doc template that generates all LAB, LCBD, FS and ES for the logical architecture.
I hope this helps.


Thx Stephane,
This does not work.
_I have added the nsuri stuff. Where is this documented, how can we know that we need to untick the capella option and that we need to add what you suggested with those specific versions 1.0.0 and not the 1.1.0 ( for example for the tree one it seems we cant have both).
Why don’t we add them all?
_Where is it documented that we need to use one function asImage and not another (e.g. ASIMAGEBYREPRESENTATIONDESCRIPTIONNAME) as described in other forums?
_I have changed the code accordingly but this still does not work i.e I have the names of the component generated but not the diagrams and no validation errors.
M2doc is unprecedently confusing… I have read all the documentations available, and many, many forums pages…I mean just basic stuff like: define your main variable as the name of the project is written nowhere!
Thank you again for your help!

Well, all this is documented in the documentation:

  • The entry point for the M2Doc documentation:
  • The M2Doc services you are using to get diagrams are documented here:
  • The fact that you have to add the NSUris is documented here:
    But indeed, being able to write your own Word template with m2doc will require you to learn a few things including the AQL query language, so if you don’t have time to do this, we offer training services or sub-contracting services to write templates for you.
    Nevertheless, I am sorry that what I sent you is still not working for you. If you want more help, I would like to know which Capella version you installed and which m2doc version you installed, and then maybe you can attach your word template so that I can see if there is something wrong.
    You can use asImage() and ASIMAGEBYREPRESENTATIONDESCRIPTIONNAME(), they will both get you an image, but these function does not apply on the same object. The reason why I am using asImage is that I used representationByDescriptionName which enables you to get the Diagram Representation object, not the image. On this object you can apply the asImage() to get the diagram image, but also .name to get the actual diagram name.
    I hope this helps

I also noticed that the example “in flight entrertainment” this option in the tab service expert in “edit the template”: “Org.obeonetwork.capella.m2doc.aql.queries.M2DocGenServices”.
Is this another tricky compulsory option to be aware of?
I cannot add anything in the tab service expert ( no suggestions and no ability to add it manually in the filter).
What should I do?
Is this necessary for m2doc to function?
What is an explicit constructor described in the m2doc documentation ? Do I have to use the explicit or the default to display nominal diagrams?
The m2doc documentation specifies this:
" When there is an explicit constructor with at least a parameter M2Doc can’t instantiate your class since there is no default constructor. You need to implement the IServicesConfigurator interface. This interface link one or more options in the generation configuration to the service class in order to instantiate it. You need to use the org.obeonetwork.m2doc.ide.servicesConfigurator extension point to declare your implementation of IServicesConfigurator. If you want to use your implementation in standalone you can register it programmatically using M2DocUtils.registerServicesConfigurator()."
Again thank you so much, this is really making me crazy I was supposed to work on my complex engineering model…and I end up loosing time on …a word template…

I understand now why you are struggling, you started over from an empty word document.
What I would suggest you is to start over reusing one of the example word document provided with the example project, it would make it simpler, just empty the content and start writing your document.
Nevertheless, if you still want to use your own word document from scratch, then this is feasible, here is the list of what you have to do, using “Edit Template properties”, to add Capella’s metamodels and other services.:

  • add all Capella’s metamodels in the “nsuri (expert)” tab (In the add dialog you can enter “capella” in the filter field then select every nsuris and add them), also keeping the one you already added previously
  • add services you can use the “services (expert)” tab on the same wizard page and add: org.obeonetwork.capella.m2doc.aql.queries.M2DocGenServices
  • click next and add a self variable with the value capellamodeller::SystemEngineering
    Click finish to save your changes, you can now open the template in MS Word to edit it.
    If you can’t edit some of the properties, you can do it in word. Go to File->info and on the right, you’ll see “Properties” and just at the end of this word, an arrow, click on it and go to “Advanced Properties” and then custom and there you can add properties.
    Once again, it is much simpler to start with a word document already provided as an example…
    A Custom Constructor is a Constructor you provide yourself in a Class.
    I hope this helps

I am sorry but I have tried everything: the M2doc template and/or project and the creation of word myself.
The wizard is not acting so much as a wizard as as I never have the Org.obeonetwork.capella.m2doc.aql.queries.M2DocGenServices.
As I said…I cannot select anything here, and there are no suggestions in the filter, not even the possibility to type manually " org.obeonetwork…". see attached.

obeo org service not there .PNG
Impossible to select or add anything, no suggestions from a wizard .jpg
obeo org service not there .PNG
Impossible to select or add anything, no suggestions from a wizard .jpg

Please attach your word document and I will fix this.

Thank you very much. Please see attached.


Please try with this one, I should have fixed the template properties.


Thank you and thank you for being reactive.
Still no diagrams are displayed though… :frowning:

ok, this is working on my end. Any error on your end? Could you sent de genconf file as well?
Can you tell me what Capella version you are using and what m2doc version you’ve installed?

I am using Capella 1.4 and M2doc 3.0.
I have no error when I use your suggested code. But I still cannot display anything with it.
However, I just found out that for the system analysis if I use this function:
"self.containedSystemAnalysis.ownedSystemComponentPkg->closure(cPkg | cPkg.ownedSystemComponentPkgs).asImageByRepresentationDescriptionName(‘System Architecture Blank’).
I can manage to display the system architecture.
and with this:
package.asImageByRepresentationDescriptionName(‘Missions Capabilities Blank’).
I can display the capabilities diagram.
Why do you think the function asimagerepresentationdescriptionname works and not the function asImage as you suggested?
Does that mean we need different functions for different analysis for ops, system, local analysis?
For me at this point for my project, the most critical ones will be displaying the exchange scenarios of the logical and system analysis.
Thank you.
King regards,

Could you make a zip of your project and send it to me? I would like to see why it is not working for you and give you the right code so that it works for you.
About the asimagerepresentationdescriptionname and asImage functions: they would both work I assume, but there must be something wrong on the code before this…

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