本人初学VBA,请各位多多指教,这段代码为什么不行
找到实体层中各直线的交点,并把它们打印出来.
Sub findpoint() Dim newlayer As AcadLayer Dim intpoints As Variant Set newlayer = ThisDrawing.Layers("实体层") ThisDrawing.ActiveLayer = newlayer For Each lineobj1 In ThisDrawing.ModelSpace For Each lineobj2 In ThisDrawing.ModelSpace If lineobj1.ObjectID <> lineobj2.ObjectID Then intpoints = lineobj1.IntersectWith(lineobj2.acExtendNone) End If Next Next Dim i As Integer, j As Integer, k As Integer Dim str As String
If VarType(intpoints) <> vbEmpty Then For i = LBound(intpoints) To UBound(intpoints) str = "Intersection Point[" & k & "] is: " & intpoints(j) & "," & intpoints(j + 1) & "," & intpoints(j + 2) MsgBox str, , "IntersectWith Example" str = "" i = i + 2 j = j + 3 k = k + 1 Next End If End Sub 谢谢大家了 |