vba - 如何使用vba在多个点之间绘制折线
问题描述
我正在尝试将 vba 中多个点之间的折线绘制到 AutoCAD 中。我几乎完成了我的代码,但问题是这些点可能会重复,因为 2 行可以有相同的起点,而这些点也不是排序的。我需要能够添加所有点,即使它们没有排序,因为我必须保持我试图绘制的点的顺序。我收到此错误:
Invalid Procedure or argument call
Set acadPol = acadDoc.ModelSpace.AddLightWeightPolyline(Points)
这是我的代码:
Points(1)=9736.242889: Points(2)=9954.553808
Points(3)=9718.429708: Points(4)=9936.874562
If acadDoc.ActiveSpace = acModelSpace Then
Set acadPol = acadDoc.ModelSpace.AddLightWeightPolyline(Points)
Else
Set acadPol = acadDoc.PaperSpace.AddLightWeightPolyline(Points)
End If
acadPol.Closed = False
acadPol.Update
End If
End If
解决方案
您的代码不完整,但我注意到您已从索引 1 开始您的坐标列表。
网上有很多例子
Sub Example_AddLightWeightPolyline()
' This example creates a lightweight polyline in model space.
Dim plineObj As AcadLWPolyline
Dim points(0 To 9) As Double
' Define the 2D polyline points
points(0) = 1: points(1) = 1
points(2) = 1: points(3) = 2
points(4) = 2: points(5) = 2
points(6) = 3: points(7) = 2
points(8) = 4: points(9) = 4
' Create a lightweight Polyline object in model space
Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
ZoomAll
End Sub
如您所见,您需要从索引 0 而不是 1 开始坐标数组。
这有帮助吗?
推荐阅读
- r - ugarchfit / ugarchforecast 是不确定的吗?
- python - OLS 汇总值在每次运行时都会发生变化
- javascript - 如何将 Jquery 导入 React
- java - 我们可以在应用程序之外创建一个弹出窗口吗?(安卓工作室)
- javascript - 如何将类添加到下一个 DIV 并使用动态数量的项目淡出当前 - 多个实例
- gnuplot - 在 gnuplot 中获取当前输出文件
- python - Django 将导致 404 的路径加倍
- curl - 自动输入用户名和密码以连接到 SFTP 服务器
- google-chrome-devtools - 与 workbox-window.update() 的行为不一致
- python - 如何从主 python 脚本重新启动正在运行的 python 脚本?