Problems accessing Diagrams inside DataPkg in M2Doc

Hello!

I have been fighting with this for a few months already and have checked all the solutions provided within this forum to extract diagrams for the M2Doc, the ones that do work extract way too many diagrams that are non related

Let’s say we have

In the model interpreter I can easily find the diagram

However in M2Doc interpreter this gives empty results. If I try the self.eAllContents().representationsByDescriptorName method it returns all diagrams that have the same descriptor instead of only the children, if I use viewpoint::DRepresentationDescriptor.allInstances().target.id ->select(d | d = ‘id‘) it returns the data package just fine

But I would need to get the Diagram out to use in M2Doc, if I were to try putting .target.id with or without the .toString() the result is

While d.target = ‘self‘ simply returns empty

I believe this is my lack of knowledge, so it would be great if you could help me out here, I am very lost! Thanks a lot and best regards!

Hi,

You can use the getSBQuery() service to get the result from the semantic browser:

myCapellaElement.getSBQuery('All Related Diagrams')

I’m not sure if it retruns a list of DDiagram or a list of DRepresentationDescriptor:

myCapellaElement.getSBQuery('All Related Diagrams').asImage()

or

myCapellaElement.getSBQuery('All Related Diagrams').representation.asImage()

To use the service you need to import the service class in the template:

org.obeonetwork.capella.m2doc.aql.queries.M2DocGenServices
1 Like

Hi! Thanks a lot for your answer, I have the services imported

However I am getting the error “ERROR: Couldn’t find the ‘getSBQuery(EClassifier=DataPkg,java.lang.String)’ service (4, 39)“ when trying to do self.getSBQuery(‘All Related Diagrams‘) - cant add screenshot because it only lets me one per publication!

Thanks for your help! Best regards

Did you test in the M2Doc Interpreter view or by generating the document ?
Aso I pasted some code with wrong quotes (‘‘ instead of ‘’ I hope they are not transformed by the forum…) so you might want to check you quotes.

This should look like this:

1 Like

its fine I remade the quotes! The document gives the same error, maybe the issue is me using self? Although selection gives the same result Im afraid

Thanks a lot!

Maybe you need to update M2Doc extensions for Capella. I don’t remember when the service has been added but older versions probably don’t have it.

You can try:

viewpoint::DRepresentationDescriptor.allInstances()->select(d | d.target.id = 'id')

or

viewpoint::DRepresentationDescriptor.allInstances()->select(d | d.target = myCapellaElement)
1 Like

viewpoint::DRepresentationDescriptor.allInstances()->select(d | d.target = selection)

seems to be the solution! Thank you so so much for your patience and for all your help!

2 Likes