You create a model using the CreateModel (modelkind As Long, filename As String = "", flags As Long =omf_Default) As BaseObject global function together with the cls_Model constant prefixed with the Module name to identify the type of model you want to create.
Note that additional arguments may be specified in the filename parameter depending on the type of model (Language, DBMS, Copy, Diagram). The diagram argument uses the public name, but the localized name (the one in the Target selection dialog box) is also accepted. However, it is not recommended to use the localized name as your script will only work for the localized version of PowerDesigner.
Option Explicit ' Call the CreateModel global function with the following parameters: ' - The model kind is an Object Oriented Model (PdOOM.Cls_Model) ' - The Language is enforced to be Analysis ' - The first diagram will be a class diagram ' - The language definition (for Analysis) is copied inside the model ' - The first diagram will not be opened in a window ' - The new created model will not appear in the workspace Dim NewModel set NewModel = CreateModel(PdOOM.Cls_Model, "Language=Analysis|Diagram=ClassDiagram|Copy", omf_DontOpenView Or omf_Hidden) If NewModel is Nothing then msgbox "Fail to create UML Model", vbOkOnly, "Error" ' Display an error message box Else output "The UML model has been successfully created" ' Display a message in the application output window ' Initialize model name and code NewModel.Name = "Sample Model" NewModel.Code = "Sample" ' Save the new model in a file NewModel.Save "c:\temp\MySampleModel.oom" ' Close the model NewModel.Close ' Release last reference to the model object to free memory Set NewModel = Nothing End If