不确定顶点数目的情况下怎么绘制多段线?
<P>点的数量是由变量给定,需要据此生成多端线,怎么用vba实现呢?</P><P>先谢谢了!</P> <P>不能先学定数目再画吗?</P> <P>想连续生成截面,每个截面复杂程度不一样啊。</P> Dim index As Integer
index = 2
Dim pt1 As Variant
pt1 = ThisDrawing.Utility.GetPoint(, "输入第一点:")
If Err Then
Err.Clear
Exit Sub
End If
Dim ptPrevious As Variant, ptCurrent As Variant
ptPrevious = pt1
nextpt:
ptCurrent = ThisDrawing.Utility.GetPoint(ptPrevious, "输入下一点:")
If Err Then
Err.Clear
Exit Sub
End If
Dim objPline As AcadLWPolyline
If index = 2 Then
Dim points(0 To 3) As Double
points(0) = ptPrevious(0)
points(1) = ptPrevious(1)
points(2) = ptCurrent(0)
points(3) = ptCurrent(1)
Set objPline = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
ElseIf index > 2 Then
Dim ptVert(0 To 1) As Double
ptVert(0) = ptCurrent(0)
ptVert(1) = ptCurrent(1)
objPline.AddVertex index - 1, ptVert
End If
index = index + 1
ptPrevious = ptCurrent
GoTo nextpt
是不是要这样?
<P>嗯,就是楼上这个方法了,用不断添加点的方式实现,谢谢!</P> 为什么不用sendcommand呢?
页:
[1]