Deleting an Object by Script

You delete an object from a model using the Delete As Boolean method.

Example

If not ExistingModel is Nothing Then
 ' Create another class first
 Dim MyClassToDelete
 Set MyClassToDelete = ExistingModel.Packages.CreateNew()
 If not MyClassToDelete is Nothing then
  output "The second class has been successfully created"
  ' Just call Delete method to delete the object
  ' This will remove the object from the collection of model classes
  MyClassToDelete.Delete
  ' The object is still alive but it has notified all other
  ' objects of its deletion. It is no more associated with other objects.
  ' Its status is deleted
  If MyClassToDelete.IsDeleted() Then
   output "The second class has been successfully deleted"
  End If
  ' The reset of the VbScript variable will release the last
  ' reference to this object abd provoke the physical destruction
  ' and free the memory
  Set MyClassToDelete = Nothing
 End If
End If