Managing MagicDraw Diagrams

When reading or writing a MagicDraw model, some extra properties are set for diagrams:

Because MagicDraw does not use the SysML OMG types in its model, the MagicDraw SysML types has to be set in the type property.

Creating a MagicDraw SysML Block Definition Diagram

Here is a sample code that shows how to create a Block Definition Diagram:
Diagram umlDiagram = model.create(UMLPackage.Literals.DIAGRAM);
umlDiagram.setSemanticTypeInfo(UMLDiagramKind.CLASS_DIAGRAM.getLiteral());
umlDiagram.setProperty(SysMLDiagramKind.SYSML_PROPERTY_KEY, SysMLDiagramKind.SYSML_BLOCK_DEFINITION_DIAGRAM.getLiteral());
umlDiagram.setProperty("type", MagicDrawSysMLDiagramKind.SYSML_BLOCK_DEFINITION_DIAGRAM.getName());
All SysML Diagram kinds are available in the Class com.sodius.mdw.metamodel.uml21.xmi.di.SysMLDiagramKind.
All MagicDraw SysML Diagram kinds are available in the Class com.sodius.mdw.metamodel.uml21.io.md.MagicDrawSysMLDiagramKind.

Creating a MagicDraw UPDM2 OV-2 Operational Resource Flow Description Diagram

Here is a sample code that shows how to create an Operational Resource Flow Description Diagram:
Diagram umlDiagram = model.create(UMLPackage.Literals.DIAGRAM);
umlDiagram.setSemanticTypeInfo(UMLDiagramKind.CLASS_DIAGRAM.getLiteral());
umlDiagram.setProperty(UPDM2ViewKind.UPDMPROPERTY_KEY, UPDM2ViewKind.OV_2.getLongName());
umlDiagram.setProperty("type", MagicDrawUPDM2DiagramKind.OV_2_OPERATIONAL_RESOURCE_FLOW_DESCRIPTION.getName());
All UDPM2 Diagram kinds are available in the Class com.sodius.mdw.metamodel.uml21.xmi.di.UPDM2ViewKind.
All MagicDraw UPDM2 Diagram kinds are available in the Class com.sodius.mdw.metamodel.uml21.io.md.MagicDrawUPDM2DiagramKind.

Related concepts
Diagram Interchange

Related tasks
Managing Diagrams
Managing a SysML Diagram

Related reference
MDAccess for UML API Reference