@tim11_manhhieu Hi, the code "-4" identify a logic operator, as "OR" is.
in the specific issue I ask to filter all object type required (circle with diameter) Higher than XXX or Lower than ("<OR" or "OR>").
In any case I guess it will be more easy select all "CIRCLE" object and later select object only with diameter required.
Could you try as follow (your code little bit modified):
Sub test4()
Dim varType As Variant
Dim varData As Variant
' BuildFilter varType, varData, 0, "TEXT", 8, "0"
BuildFilter varType, varData, 0, "Circle" '-4, "<OR", -4, ">=", 40, 5, -4, "OR>"
Dim ss1 As AcadSelectionSet
' Dim arEnts() As AcadText
Set ss1 = AddSelectionSet("ss1")
ss1.Select acSelectionSetAll, , , varType, varData
'
' ReDim arEnts(0 To ss1.Count - 1)
' Dim ent As Object ' AcadText
Dim i As Integer
i = 0
' Dim cnt As Object
cnt = 0
For Each Nent In ss1
If TypeOf Nent Is AcadCircle Then
Set MyEnts = Nent
If MyEnts.Diameter >= 35 And MyEnts.Diameter <= 35 Then
Debug.Print ss1.Count & " entities found. Diameter: " & MyEnts.Diameter
i = i + 1
End If
End If
Next Nent
' ReDim arEnts(0 To i - 1)
End Sub
Public Sub BuildFilter(typeArray As Variant, dataArray As Variant, ParamArray gCodes())
'Purpose
'Fills a pair of variants with arrays for use as a selection set filter
'
'Arguments
'Two variants (not variant arrays) and an unlimited number of group code / value pairs
'
'Example
'BuildFilter fType, fData, 0, "LINE", 7, "WALLS"
Dim fType() As Integer, fData()
Dim index As Long, i As Long
index = LBound(gCodes) - 1
For i = LBound(gCodes) To UBound(gCodes) Step 2
index = index + 1
ReDim Preserve fType(0 To index)
ReDim Preserve fData(0 To index)
fType(index) = CInt(gCodes(i))
fData(index) = gCodes(i + 1)
Next
typeArray = fType: dataArray = fData
End Sub
Public Function AddSelectionSet(SetName As String) As AcadSelectionSet
' This routine does the error trapping neccessary for when you want to create a
' selectin set. It takes the proposed name and either adds it to the selectionsets
' collection or sets it.
On Error Resume Next
Set AddSelectionSet = ThisDrawing.SelectionSets.Add(SetName)
If Err.Number <> 0 Then
Set AddSelectionSet = ThisDrawing.SelectionSets.Item(SetName)
AddSelectionSet.Clear
End If
End Function
Where you will found all "CIRCLE"s with Selection Set and later check the diameter.
If you have more than one diameter you can add to your code a Select Case function
Select Case XXX (item in selection set)
Case XXX (item in selection set) is XXX
...do something
Case YYYY (item in selection set)
....do something of other
End Select