How to obtain captions independently from diagrams?

Hi,

I want to generate diagrams from a model, but I have found difficulties to extract the caption of the diagram. I am using this:

{ m:for comp | self.eAllContents() }

{ m:if comp.isRepresentationDescriptionName(‘Logical Architecture Blank’) }
{ m:for image.asImageByRepresentationDescriptionName('Logical Architecture Blank) }

{ m:image.setWidth(400) }
Caption : { m: comp.representationByDescriptionName('Logical Architecture Blank).name }

{ m:endfor }
{ m:endif }

{ m:endfor }

With this, I obtain the LAB diagrams and all the caption of all the diagrams every time. I assume representationByDescriptionName() gives a Sequence, but I don’t know hoy to access independently to every caption.

Thanks,
I.B.

Yes you need to directly work with the DRepresentation in the second for loop:

{ m:for comp | self.eAllContents() }

{ m:if comp.isRepresentationDescriptionName('Logical Architecture Blank') }
{ m:for representation | comp.representationByDescriptionName('Logical Architecture Blank') }

{ m:representation.asImage().fit(400, 400) }
Caption : { m: representation.name }

{ m:endfor }
{ m:endif }

{ m:endfor }

This way for each DRepresentation you can extract it as an image and also get its name. I used the fit() service that will resize an image to fit in a rectangle, but you can stick with the setWidth() service if you want.