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

但是运行提示无效的过程调用或参数,求教问题出在哪里?
展开
 我来答
灰机灰过5
2019-03-29 · 专注于CAD和Excel,道路桥梁专业
灰机灰过5
采纳数:582 获赞数:1629

向TA提问 私信TA
展开全部
因为你定义的时候数组定义错了,point3(0 To 2), point4(0 To 2)应该改为dim point3(0 To 2) as double
dim point4(0 To 2) as double
很多时候为了方便省事都是这样定义的:dim a,b,c,d,e as double .可是这样定义除了e是double型其余的全是variant。
直线数组的startpoint和endpoint两个参数必须要定义成double型才行的
suchuanok
2016-12-10 · TA获得超过131个赞
知道答主
回答量:128
采纳率:50%
帮助的人:39.9万
展开全部
大胸弟,受教了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式