Delete all objects - autocad vba

Submitted by timed on Tue, 12/25/2018 - 11:22

Public Sub deleteall()

Set newss = vbdPowerSet("tests")

    newss.Select acSelectionSetAll 'select all entities (no filters)
    For Each objEntity In newss


    newss.Delete 'delete the selection set object (not the entities)

End Sub



Public Function vbdPowerSet(strName As String) As AcadSelectionSet

  Dim objSelSet As AcadSelectionSet

  Dim objSelCol As AcadSelectionSets

  Set objSelCol = ThisDrawing.SelectionSets

    For Each objSelSet In objSelCol

      If objSelSet.Name = strName Then


        Exit For

      End If


  Set objSelSet = objSelCol.Add(strName)

  Set vbdPowerSet = objSelSet

End Function