This service is archived, please use

Home » Capella » Capella Studio » Create diagram programmatically (How to create diagram programmatically)
Create diagram programmatically [message #3562] Tue, 01 October 2019 08:09 Go to next message is currently offline
Messages: 37
Registered: April 2019

I try to create a "Physical Architecture Blank" diagram programmatically but I don't find topic to help me.

Who can help me ?

Re: Create diagram programmatically [message #3574 is a reply to message #3562] Thu, 10 October 2019 04:01 Go to previous message is currently offline
Messages: 37
Registered: April 2019

I finally find how to do and want to share it we all :

public void createDiagram(String pathName, String representationName, EObject sementic, String representationDescriptionName) {

URI representationsFileURI = URI.createPlatformResourceURI(pathName, true);

Session session = SessionManager.INSTANCE.getSession(
representationsFileURI, new NullProgressMonitor());

Collection<DRepresentation> representations= getRepresentations(session, representationDescriptionName);

Map<String, DRepresentation> map = new HashMap<>();

Iterator<DRepresentation> it =representations.iterator();
DRepresentation representation = null;

while(it.hasNext()) {
representation =;
map.put("0", representation);

createDRepresentation(representationName, sementic, getDescription(representation), session, new NullProgressMonitor());


public Collection<DRepresentation> getRepresentations(final Session session, final String representationDescriptionName) {
final Collection<DRepresentation> allRepresentations = DialectManager.INSTANCE.getAllRepresentations(session);

final Collection<DRepresentation> representations = new HashSet<DRepresentation>();

for (final DRepresentation representation : allRepresentations) {
final RepresentationDescription desc = DialectManager.INSTANCE.getDescription(representation);
if (desc != null && representationDescriptionName.equals(desc.getName())) {
return representations;

public DRepresentation createDRepresentation(String name, EObject semantic, RepresentationDescription description,
Session session, IProgressMonitor monitor) {
return DialectManager.INSTANCE.createRepresentation(name, semantic, description, session, monitor);
Previous Topic: Import Component from excel
Next Topic: XText grammar generation issue in Capella Studio
Goto Forum:

Current Time: Fri Jun 05 19:39:37 EST 2020

Total time taken to generate the page: 0.01543 seconds