cad vba 求多段线与直线交点坐标的问题 20
我想实现分别绘制两条多段线,然后再绘制一条直线,利用CADVBA来得到两个交点坐标。我的代码如下:PublicSubtee()Dimpoint1(0To3),point2...
我想实现分别绘制两条多段线,然后再绘制一条直线,利用CAD VBA来得到两个交点坐标。我的代码如下:
Public Sub tee()
Dim point1(0 To 3), point2(0 To 3), point3(0 To 2), point4(0 To 2), p As Variant
Dim entLine1 As AcadLWPolyline, entLine2 As AcadLWPolyline, entLine3 As AcadLine
point1(0) = 0: point1(1) = 0
point1(2) = 5: point1(3) = 5
point2(0) = 0: point2(1) = 8
point2(2) = 8: point2(3) = 8
point3(0) = 3
point3(1) = 0
point3(2) = 0
point4(0) = 3
point4(1) = 2
point4(2) = 0
Set entLine3 = ThisDrawing.ModelSpace.AddLine(point3, point4)
Set entLine1 = ThisDrawing.ModelSpace.AddLightWeightPolyline(point1)
Set entLine2 = ThisDrawing.ModelSpace.AddLightWeightPolyline(point2)
Dim intPoints1, intPoints2 As Variant
intPoints1 = entLine3.IntersectWith(entLine1, acExtendBoth)
intPoints2 = entLine3.IntersectWith(entLine2, acExtendBoth)
MsgBox "直线1和直线2的交点:交点1坐标为" & intPoints1(0) & " " & intPoints1(1) & " " & intPoints1(2)
MsgBox "直线1和直线3的交点:交点1坐标为" & intPoints2(0) & " " & intPoints2(1) & " " & intPoints2(2)
End Sub
但是运行提示无效的过程调用或参数,求教问题出在哪里? 展开
Public Sub tee()
Dim point1(0 To 3), point2(0 To 3), point3(0 To 2), point4(0 To 2), p As Variant
Dim entLine1 As AcadLWPolyline, entLine2 As AcadLWPolyline, entLine3 As AcadLine
point1(0) = 0: point1(1) = 0
point1(2) = 5: point1(3) = 5
point2(0) = 0: point2(1) = 8
point2(2) = 8: point2(3) = 8
point3(0) = 3
point3(1) = 0
point3(2) = 0
point4(0) = 3
point4(1) = 2
point4(2) = 0
Set entLine3 = ThisDrawing.ModelSpace.AddLine(point3, point4)
Set entLine1 = ThisDrawing.ModelSpace.AddLightWeightPolyline(point1)
Set entLine2 = ThisDrawing.ModelSpace.AddLightWeightPolyline(point2)
Dim intPoints1, intPoints2 As Variant
intPoints1 = entLine3.IntersectWith(entLine1, acExtendBoth)
intPoints2 = entLine3.IntersectWith(entLine2, acExtendBoth)
MsgBox "直线1和直线2的交点:交点1坐标为" & intPoints1(0) & " " & intPoints1(1) & " " & intPoints1(2)
MsgBox "直线1和直线3的交点:交点1坐标为" & intPoints2(0) & " " & intPoints2(1) & " " & intPoints2(2)
End Sub
但是运行提示无效的过程调用或参数,求教问题出在哪里? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询