思路:选一条多段线,程序自动创建5条线,求交点
问题:所求交点重合为一个点???请高手指点。谢谢。
Dim ent As AcadEntity
On Error Resume Next N = -1 Do ThisDrawing.Utility.GetEntity ent, Pnt, "选择区域范围线(多段线):" If Err Then Exit Sub If TypeName(ent) Like "IAcad*Polyline" Then Exit Do
Loop Dim StartPt(0 To 2) As Double, EndPt(0 To 2) As Double
For u = 1 To 5 StartPt(0) = 100 + (u - 1) * 5 StartPt(1) = 100 StartPt(2) = 0 EndPt(0) =120 + (u - 1) * 5 EndPt(1) = 120
EndPt(2) = 0 Dim LineObj As AcadLine Set LineObj = ThisDrawing.ModelSpace.AddLine(StartPt, EndPt) LineObj.Update intPoints = LineObj.IntersectWith(ent, acExtendThisEntity) Dim str As String Dim pointObj As AcadPoint '声明点的对象变量 Dim Location(0 To 2) As Double '声明点的位置数组变量 If VarType(intPoints) <> vbEmpty Then For i = LBound(intPoints) To UBound(intPoints) str = "Intersection Point[" & k & "] is: " & Format(intPoints(j), "0.000") & "," & Format(intPoints(j + 1), "0.000") & "," & intPoints(j + 2) 'MsgBox str, , "IntersectWith Example" Location(0) = Format(intPoints(j), "0.000") Location(1) = Format(intPoints(j + 1), "0.000") Location(2) = 0 Set pointObj = ThisDrawing.ModelSpace.AddPoint(Location) str = "" i = i + 2 j = j + 3 k = k + 1 Next i End If Next u
|