Delete Example

AEC Auto

Delete Example

Sub Example_Delete()

   ' This example prompts users to select a drawing object, then
   ' deletes that object. It then issues the Undo command to
   ' reverse the delete.

   Dim obj As AcadObject
   Dim ent As AecEntity
   Dim pickPt As Variant

   On Error Resume Next
   ThisDrawing.Utility.GetEntity obj, pickPt, "Please select an AEC object:" & vbCrLf
   On Error GoTo 0
    
   ' Verify that an AEC object was selected.
   If obj Is Nothing Then
      MsgBox "Nothing selected.", vbExclamation, "Delete Example"
      Exit Sub
   ElseIf Not (TypeOf obj Is AecEntity) Then
      MsgBox "The object you selected is not an AEC object.", vbExclamation, "Delete Example"
      Exit Sub
   Else
      Set ent = obj
      Set obj = Nothing
   End If

   ' Delete the selected object.
   ent.Delete
   ThisDrawing.Regen (acActiveViewport)
   MsgBox "The selected object was temporarily deleted.", vbExclamation, "Delete Example"

   ' Undo the delete.
   ThisDrawing.SendCommand "_undo" & vbCr & vbCr

End Sub