Search code examples
javascriptscriptingumlenterprise-architect

How to create diagram "Requirements Diagram" with JavaScript in Enterprise Architect


Using scripting in Enterprise Architect I can create diagram Use Case of UML:

testElement = subPackage.Elements.AddNew( "New diagram", "Use Case" );
testElement.Update();

But how to create non-UML diagram? It's about second parameter of AddNew function. In documentation, there is

This can be either a standard UML metaclass type (such as 'Class' or 'UseCase') or a fully-qualified metatype defined by an MDG Technology (such as 'BPMN2.0::BusinessProcess' or 'SysML1.4::Block').

But what is fully-qualified metatype defined by an MDG Technology? I tried something like "Extended::Requirements Diagram", but it didn't work.


Solution

  • You can't add a Diagram in the Elements collection.

    The code you posted creates a Use Case , not a diagram.

    So the correct code would be

    newDiagram = subPackage.Diagrams.AddNew( "New diagram", "Extended::Requirements" );
    newDiagram.Update();