采用功能函数实现选择集中对象的增加。- Function CreatSelectionSet(InputEntityObjectName As Variant) As AcadSelectionSet
- On Error Resume Next
- 'Dim SSet As AcadSelectionSet
- If Not IsNull(ThisDrawing.SelectionSets.Item("SelectEntity")) Then
- Set CreatSelectionSet = ThisDrawing.SelectionSets.Item("SelectEntity")
- CreatSelectionSet.Delete
- End If
- Set CreatSelectionSet = ThisDrawing.SelectionSets.Add("SelectEntity")
- Pt1 = ThisDrawing.Utility.GetPoint(, "Input First Point")
- Pt2 = ThisDrawing.Utility.GetPoint(Pt1, "Input First Point")
- Dim gpCode(0) As Integer
- Dim dataValue(0) As Variant
- gpCode(0) = 0
- For ii = 0 To UBound(InputEntityObjectName)
- dataValue(ii) = InputEntityObjectName(ii)
- Next ii
- CreatSelectionSet.Select acSelectionSetWindow, Pt1, Pt2, gpCode, dataValue
- End Function
- Sub ReadTable()
- Dim SSet As AcadSelectionSet
- Dim InputEntityObjectName As Variant
- InputEntityObjectName = Array("Text")
- Set SSet = CreatSelectionSet(InputEntityObjectName)
- Dim Ent As AcadEntity
- For Each Ent In SSet
- Debug.Print Ent.ObjectName
- Next Ent
- End Sub
|