@sunchuanpu
Hi, I'm not a professional programmer of VBA, all what I know I learned myself looking and participating to forums like this.
I'll try to explain how selectionset works with some code, and side explanation.
First of all you have to keep in mind how the selection set is searching the objects, it's based upon the same code used when you export a dwg in dxf format, there are two arrays which are determining the type of object or sometime logical function, or directly a string.
Here a link to help web page where you can find the code http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-2553CF98-44F6-4828-82DD-FE3BC7448113
Here an example of code:
Sub selectLine()
Dim sset As AcadSelectionSet
Set sset = ThisDrawing.SelectionSets.Add("TestSet2")
Dim filterType As Variant
Dim filterData As Variant
Dim p1(0 To 2) As Double
Dim p2(0 To 2) As Double
Dim grpCode(0) As Integer
grpCode(0) = 2
filterType = grpCode
Dim grpValue(0) As Variant
grpValue(0) = "Line"
filterData = grpValue
sset.Select acSelectionSetAll, p1, p2, filterType, filterData
Debug.Print "Entities: " & str(sset.count)
For Each ObjectLine in sset
If type of ObjectLine is AcadLine then
Debug.print ObjectLine.Endpoint(0), ObjectLine.Endpoint(1)
End if
Next
sset.Delete
End Sub
All Objects found by Selection Set will be stored in sset variable, and inside Item(x) you can find each object with own properties. Use debug to see all properties, count, and so on.
Above I have inserted P1, and P2 that could be used if a selection window shall be used, on the opposite you can use ", ," instead P1 and P2.
Above code shall be tested, I can't, because actually I'm working with another machine without Autocad installed.
I'll check within today, however it should work fine.
Regards