Creating Shortcuts (Scripting)

You create a shortcut in a model using the CreateShortcut() method.

The following script acts on an OOM and creates a shortcut of the class C1 from package P1 in package P2:
Dim obj, shortcut, recipient
' Get class to shortcut
Set obj = ActiveModel.FindChildByPath("P1/C1",cls_Class)
' Get package to create shortcut in
Set recipient = ActiveModel.FindChildByPath("P2",PdOOM.cls_Package)
' Create shortcut
Set shortcut = obj.CreateShortcut(recipient)
If not shortcut is nothing then
  output "The class shortcut has been successfully created"
End If
The following script creates a shortcut of the class C1 from model O1 package P1 directly under model O2:
Dim targetmodel, usingmodel, obj, shortcut
For each m in Models
   Output m.Name
   If m.Name="O1" then 'Get model with object to shortcut
      Set targetmodel=m
   End If
   If m.Name="O2" then 'Get model to create shortcut in
      Set usingmodel=m
   End If
Next
' Get object to shortcut
Set obj = targetmodel.FindChildByPath("P1/C1",cls_Class)
' Create shortcut
Set shortcut = obj.CreateShortcut(receivingmodel)
If not shortcut is nothing then
  output "The class shortcut has been successfully created"
End If