Selection Set Filter
Published on Monday, 30 March 2009 17:33
The code below is a sample of how to filter a selection before its added to a selection set. This example uses two filter. One to filter that the objetc is a Line and the other criteria is that it has to reside on the layer called "0".
Dim ss As AcadSelectionSet
Dim FilterType(0) As Integer
Dim FilterData(0) As Variant
Set ss = CreateSelectionSet("SStemp")
FilterType(0) = 0
FilterData(0) = "Circle"
FilterType(1) = 8
FilterData(1) = "0"
ss.Select acSelectionSetAll, , , FilterType, FilterData
MsgBox "The selectionset contains:" & ss.Count & " entities."
Public Function CreateSelectionSet(SSset As String) As AcadSelectionSet
On Error Resume Next
Set CreateSelectionSet = ThisDrawing.SelectionSets(SSset)
If Err Then
Set CreateSelectionSet = ThisDrawing.SelectionSets.Add(SSset)
Exit Function: End If
Set CreateSelectionSet = ThisDrawing.SelectionSets.Item(SSset)
Other Filtertypes are displayed below:
0 Object Type (String) Such as “Line,” “Circle,” “Arc,” and so forth.
2 Object Name (String) The table (given) name of a named object.
8 Layer Name (String) Such as “Layer 0.”
60 Object Visibility (Integer) Use 0 = visible, 1 = invisible.
62 Color Number (Integer) Numeric index values ranging from 0 to 256.
67 Model/paper space indicator (Integer) Use 0 or omitted = model space, 1 = paper space.