如何使用vba在多个点之间绘制多段线
我正在尝试将vba中多个点之间的多段线绘制到autocad中。我几乎已经完成了我的代码,但问题是这些点可能会重复它们自己,因为两行可以有相同的起点,而且这些点也不会以排序方式重复。 我需要能够添加所有点,即使它们没有排序,因为我必须保持我试图绘制的点的顺序。 我得到这个错误:如何使用vba在多个点之间绘制多段线,vba,autocad,polyline,Vba,Autocad,Polyline,我正在尝试将vba中多个点之间的多段线绘制到autocad中。我几乎已经完成了我的代码,但问题是这些点可能会重复它们自己,因为两行可以有相同的起点,而且这些点也不会以排序方式重复。 我需要能够添加所有点,即使它们没有排序,因为我必须保持我试图绘制的点的顺序。 我得到这个错误: Invalid Procedure or argument call Set acadPol = acadDoc.ModelSpace.AddLightWeightPolyline(Points) 这是我的代码: Poi
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处启动坐标数组
这有帮助吗?请阅读最小、完整且可验证的示例:轻量级多边形线接受2d顶点列表。此外,坐标数组可能是基于零的索引。但是您的代码不完整。您甚至没有向我们展示如何声明points数组变量。