创建一个包含特定名称的所有块引用的过滤选择集的过程如下所示:
- Sub GetNamedInserts()
- Dim entbref As AcadBlockReference
- Dim TempObjSS As AcadSelectionSet
- Dim intCode(2) As Integer
- Dim varData(2) As Variant
- Dim strName As String
-
- strName = ThisDrawing.Utility.GetString(0, "Enter Block name to select: ")
- SSInit
- Set TempObjSS = ThisDrawing.SelectionSets.Add("TempSSet")
- intCode(0) = 0: varData(0) = "Insert"
- intCode(1) = 67: varData(1) = 0
- intCode(2) = 2: varData(2) = strName
- TempObjSS.Select acSelectionSetAll, , , intCode, varData
- MsgBox "There are " & TempObjSS.Count & " inserts referencing " & strName & " in Modelspace"
- End Sub
- Sub SSInit()
- Dim SSS As AcadSelectionSets
- Dim SS As AcadSelectionSet
- Set SSS = ThisDrawing.SelectionSets
- If SSS.Count > 0 Then
- For Each SS In SSS
- If SS.Name = "TempSSet" Then
- SS.Delete
- Exit For
- End If
- Next
- End If
- End Sub
还要注意,过滤器数据还可以包含通配符,以便进行更广泛的选择。例如,如果过滤器是:
intCode(2)=2:varData(2)=strName&“*”
strName为“Block”,则选择集将包括引用“Block1”、“Block2”、“Block3”等的插入。 |