Display Information About a Selection Set
 
 
 

To refer to an existing selection set whose name you know, refer to it by name. The following example refers to a selection set named “SS10:”

Sub GetObjInSet()
  Dim selset As AcadSelectionSet
  Set selset = ThisDrawing.SelectionSets("SS10")


  MsgBox ("Selection set " & selset.Name & " contains " & _
	selset.Count & " items")


End Sub

Each selection set in a drawing is a member of the SelectionSets collection. You can use the For Each statement to iterate through a drawing's SelectionSets collection and collect information about each selection set.

Display the name of each selection set in a drawing

The following code displays the name of each selection set in a drawing, and lists the types of objects included in each selection set:

Sub ListSelectionSets()
  Dim selsetCollection As AcadSelectionSets
  Dim selset As AcadSelectionSet
  Dim ent As Object
  Dim i, j As Integer


  Set selsetCollection = ThisDrawing.SelectionSets


  ' Find each selection set in the drawing
  i = 0
  For Each selset In selsetCollection
	MsgBox "Selection set " & CStr(i) & " is: " & selset.Name


	' Now find each object in the selection set, and say what it is
	j = 0
	For Each ent In selset
	 MsgBox "Item " & CStr(j + 1) & " in " & selset.Name _ 
		 & "is: " & ent.EntityName
	 j = j + 1
	Next
	i = i + 1
  Next


End Sub