21 | 09 | 2017

Selection Set Filter

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".


Sub FilterSelectionSet()
'*** Code from VisibleVisual.com ********
   Dim ss As AcadSelectionSet
   Dim FilterType(0) As Integer
   Dim FilterData(0) As Variant
   Set ss = CreateSelectionSet("SStemp")
   FilterType(0) = 0        'Indicates filter refers to an object type
   FilterData(0) = "Circle"  'Indicates the object type is "Line"
   FilterType(1) = 8        '8 Indicates a filter that refers to a layer
   FilterData(1) = "0"      'The layer resides on layer "0"
   ss.Select acSelectionSetAll, , , FilterType, FilterData

   MsgBox "The selectionset contains:" & ss.Count & " entities."

End Sub

'Code below is used to create a selectionset
Public Function CreateSelectionSet(SSset As StringAs AcadSelectionSet
'*** Code from VisibleVisual.com ********
'This Function Checks if a selection set exists
'If so it will be cleared
'If not then it will be created
On Error Resume Next
Set CreateSelectionSet = ThisDrawing.SelectionSets(SSset)
    If Err Then
    Set CreateSelectionSet = ThisDrawing.SelectionSets.Add(SSset)
    Exit FunctionEnd If
Set CreateSelectionSet = ThisDrawing.SelectionSets.Item(SSset)
End Function


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.



Sign up now and upload your code to the website.

Help us to continue.....
Articles View Hits
Latest Articles