- Public Function ssSubtract(selSet As AcadSelectionSet, subSet As AcadSelectionSet) As AcadSelectionSet
- Dim cnt As Long
- Dim i As Long
- cnt = subSet.Count
- Dim objArray() As AcadEntity
- ReDim objArray(cnt - 1)
- For i = 0 To cnt - 1
- Set objArray(i) = subSet(i)
- Next i
- selSet.RemoveItems objArray
- Set ssSubtract = selSet
- End FunctionSub ssSubSample()
- On Error Resume Next
- Dim ss1 As AcadSelectionSet
- Dim ss2 As AcadSelectionSet
- Set ss1 = ThisDrawing.SelectionSets.Add("1")
- Set ss2 = ThisDrawing.SelectionSets.Add("2")
- ThisDrawing.Utility.Prompt vbCr & "选择对象:"
- ss1.SelectOnScreen
- ThisDrawing.Utility.Prompt vbCr & "选择要减去的对象:"
- ss2.SelectOnScreen
- Set ss1 = ssSubtract(ss1, ss2)
- ss1.Highlight True
- MsgBox "已经高亮显示减去后的对象选择集", , "明经通道VBA示例"
- ss1.Highlight False
- ss1.Delete
- ss2.Delete
- End Sub
|