Deleting Objects (Scripting)

You can delete objects using the Delete method.

The following script creates a new CDM, populates it with entities and relationships, and then deletes entity E5 and relationship R8:
Dim MyModel, obj, sym, idx
set MyModel = CreateModel(PdCDM.Cls_Model)
MyModel.SetNameAndCode "MyCDM" , "MyCDM"
'Create entities
For idx = 1 to 12
   Set obj=MyModel.Entities.CreateNew()
   obj.SetNameAndCode "E" & idx, "E" & idx
   Set sym=ActiveDiagram.AttachObject (obj)
Next
'Create relationships
For idx = 2 to 11
   Set obj=MyModel.Relationships.CreateNew()
   obj.SetNameAndCode "R" & idx-1, "R" & idx-1
   Set obj.Object1 = MyModel.FindChildByName("E" & (idx-1),cls_entity)
   Set obj.Object2 = MyModel.FindChildByName("E" & (idx+1),cls_entity)
   Set sym=ActiveDiagram.AttachLinkObject (obj)
Next
ActiveDiagram.AutoLayoutWithOptions(2)
'Delete objects
MyModel.FindChildByName("E5",cls_entity).Delete
MyModel.FindChildByName("R8",cls_relationship).Delete