You create models and open existing models using the CreateModel() and OpenModel() global functions. The model with the current focus is accessible via the ActiveModel global property, and the models currently open in the workspace are available from the Models global collection.
Dim NewModel set NewModel = CreateModel(PdOOM.Cls_Model, "Language=Analysis|Diagram=ClassDiagram|Copy") If NewModel is Nothing then msgbox "Failed to create UML Model", vbOkOnly, "Error" ' Display an error message Else output "The UML model has been created" ' Display a message in Output NewModel.SetNameAndCode "MyOOM", "MyOOM" 'Initialize model name and code For idx = 1 to 12 'Create classes and display them Set obj=NewModel.Classes.CreateNew() obj.SetNameAndCode "C" & idx, "C" & idx Set sym=ActiveDiagram.AttachObject (obj) Next ActiveDiagram.AutoLayoutWithOptions(2) NewModel.Save "c:\temp\MyOOM.oom" ' Save the model NewModel.Close ' Close the model Set NewModel = Nothing ' Release last reference to object to free memory End If
Dim MyModel, FileName FileName = "c:\temp\MyOOM.oom" On Error Resume Next ' Avoid generic scripting error message Set MyModel = OpenModel(FileName) If MyModel is nothing then ' Display an error message box msgbox "Failed to open Model:" + vbCrLf + FileName, vbOkOnly, "Error" Else ' Display a message in Output output "The OOM has been opened." End If