Dim Circle1 As AcadCircle For i = 0 To ThisDrawing.ModelSpace.Count On Error Resume Next Set object = ThisDrawing.ModelSpace.Item(i) If Not Err Then For j = i To ThisDrawing.ModelSpace.Count point = object.IntersectWith(ThisDrawing.ModelSpace.Item(j), acExtendNone) If point <> "" Then ' 你要做的处理,变红或者别的 ' Set Circle1 = ThisDrawing.ModelSpace.AddCircle(point, 200) ' Circle1.Color = acRed End If Next End If Next ThisDrawing.Application.Update
Sub Example_IntersectWith() ' This example creates a line and circle and finds the points at ' which they intersect. Dim Object As AcadEntity, Object1 As AcadEntity Dim ii As Integer Dim ppt As Variant For ii = 0 To ThisDrawing.ModelSpace.Count - 1 On Error Resume Next Set Object = ThisDrawing.ModelSpace.Item(ii) If ii = ThisDrawing.ModelSpace.Count - 1 Then Set Object1 = ThisDrawing.ModelSpace.Item(0) Else Set Object1 = ThisDrawing.ModelSpace.Item(ii + 1) End If 'Debug.Print Object.Handle, Object1.Handle ppt = Object1.IntersectWith(Object, acExtendBoth) Debug.Print ii, ppt(0), ppt(1), ppt(2)