Hello,
For a project I’m working on, I’d like to generate a document that contains all diagram images of a certain type (e.g. Operational Activities, Operational Capabilities, etc.) and then print the diagram description underneath each image.
From the example template I found that I can generate a single diagram image like this:
{m:myProject.eAllContents().representationByDescriptionName('Operational Capabilities Blank').asImage().setWidth(400)}
However, I’m struggling with how to scale this beyond “trial and error” on the diagram name.
Questions:
-
The string 'Operational Capabilities Blank' seems to be the representation/description name. How can i find the discription name of a diagram?
-
Is there a way to iterate all diagrams of a certain type (e.g. all Operational Capability diagrams) in a {m:for ...} loop and export them as images? Ideally something like: filter by diagram type / viewpoint / description, then .asImage().
-
Once I have the representations, what’s the recommended way to print each diagram’s documentation/description text beneath it?
Any help or pointers to the right API/query patterns would be greatly appreciated.
Kind regards,
Gerjen
Hi Gerjen,
- You can select the diagram element by clicking on the background of the diagram. From here you can access its description name:
In the Sirius interpreter view:aql:self.description.name
In the M2Doc interpreter view:selection.description.name
In both cases you can trigger the content assist with CTRL+SPACE. But to get a better understanding of the structure of the Capella model (semantic model) and Sirius model (diagrams), you can check their metamodels:
- You can get all instances of an
EClass with the allInstances() service:viewpoint::DRepresentationDescriptor.allInstances()
Then you can select ones with the right description name:viewpoint::DRepresentationDescriptor.allInstances()->select(r | r.description.name = '...' or r.description.name = '...')
DRepresentationDescriptor is a technical element used to describe a representation without the need of loading it. From it you can access the representation itself with the representation EReference. The final loop should look something like this:{m:for descriptor | viewpoint::DRepresentationDescriptor.allInstances()->select(r | r.description.name = '...' or r.description.name = '...'}
{m:descriptor.representation.asImage()}
{m:descriptor.representation.name}
{m:descriptor.target.oclAsType(capellacore::CapellaElement).description.fromHTMLBodyString()}
{m:endfor}
The target EReference references the semantic element (it can be any model element EObject but here we need to access features from a CapellaElement) from a representation element. the fromHTMLBodyString() service converts the HTML to docx. You can find a list of M2Doc services here.
I hope this will give you a better understanding on how you can use M2Doc and AQL.
regards,
Yvan.
1 Like
Thanks for your response, this helps a lot.
You’re amazing!
1 Like