Delete Objects

You can delete individual objects by using the Delete method.

NoteThe Collection objects in ActiveX Automation have a Delete method due to the manner in which these objects have been defined in the type library. However, the Collection objects, such as ModelSpace collection, Layers collection, and Dictionaries collection, should never be deleted. An error will result if you attempt to delete a collection.

Create and delete a polyline

This example creates a lightweight polyline, then deletes it.

Sub Ch4_DeletePolyline()
	' Create the polyline
	Dim lwpolyObj As AcadLWPolyline
	Dim vertices(0 To 5) As Double
	vertices(0) = 2: vertices(1) = 4
	vertices(2) = 4: vertices(3) = 2
	vertices(4) = 6: vertices(5) = 4
	Set lwpolyObj = ThisDrawing.ModelSpace. _

' Erase the polyline
	ThisDrawing.Regen acActiveViewport
End Sub