- Sub SelectionSetFilterTest()
- Dim FilterType(0 To 1) As Integer
- Dim FilterData(0 To 1) As Variant
- Dim sSet As AcadSelectionSet
- Dim Entry As AcadEntity
- FilterType(0) = 0 '图元类型
- FilterData(0) = "INSERT"
- FilterType(1) = 2 '图元名称
- FilterData(1) = "DJ_V2"
- On Error Resume Next
- ThisDrawing.SelectionSets.Item("SS1").Delete
- Set sSet = ThisDrawing.SelectionSets.Add("SS1")
- On Error GoTo 0
-
- '显示整个图形
- ThisDrawing.Application.ZoomExtents
-
- 'sSet.SelectOnScreen FilterType, FilterData
-
- 'Select只能选择图形中可视范围内的实体
- sSet.Select acSelectionSetAll, , , FilterType, FilterData
- If sSet.Count = 0 Then Exit Sub
- For Each Entry In sSet
- Entry.color = acRed
- Entry.Update
- Next Entry
- MsgBox "修改了" & sSet.Count & "实体!"
- End Sub
|