看不懂你的,我写了一个
- Sub test()
- On Error Resume Next
- Dim obj1 As AcadEntity
- Dim pt As Variant
- ThisDrawing.Utility.GetEntity obj1, pt
- Dim bpts(0 To 11) As Double
- Dim minpt As Variant
- Dim maxpt As Variant
- obj1.GetBoundingBox minpt, maxpt
- bpts(0) = minpt(0)
- bpts(1) = minpt(1)
- bpts(2) = minpt(2)
- bpts(3) = minpt(0)
- bpts(4) = maxpt(1)
- bpts(5) = minpt(2)
- bpts(6) = maxpt(0)
- bpts(7) = maxpt(1)
- bpts(8) = maxpt(2)
- bpts(9) = maxpt(0)
- bpts(10) = minpt(1)
- bpts(11) = maxpt(2)
- Dim ss As AcadSelectionSet
- ThisDrawing.SelectionSets.Add ("test")
- Set ss = ThisDrawing.SelectionSets.Item("test")
- ss.SelectByPolygon acSelectionSetCrossingPolygon, bpts
- For Each obj In ss
- If Not (obj Is obj1) Then
- 'MsgBox "OK"
- 'Else
- Dim ipts As Variant
- ipts = obj1.IntersectWith(obj, acExtendNone)
- MsgBox "有" & (UBound(ipts) + 1) / 3 & "个交点"
- End If
- Next
- End Sub
|