dongjiajia12 发表于 2007-8-1 15:08:00

vba的一个多段线绘制问题

我用vba 编了一个程序,输入自变量范围绘制多段线,有些自变量能行有的就不行了弹出下列错误.说是 安全数组太少 或元素数目不是3的倍数,有那位高手知道怎么回事请指教。最好能给我讲讲解决的办法,我也很想和大家叫个朋友qq113080248

cppetonglei 发表于 2007-8-1 15:43:00

<p>区分两种多段线LightWeightPolyline和Polyline。详见AutoCAD ActiveX and VBA Reference</p><p>Sub Example_AddLightWeightPolyline()<br/>&nbsp;&nbsp;&nbsp; ' This example creates a lightweight polyline in model space.<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim plineObj As AcadLWPolyline<br/>&nbsp;&nbsp;&nbsp; Dim points(0 To 9) As Double<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Define the 2D polyline points<br/>&nbsp;&nbsp;&nbsp; points(0) = 1: points(1) = 1<br/>&nbsp;&nbsp;&nbsp; points(2) = 1: points(3) = 2<br/>&nbsp;&nbsp;&nbsp; points(4) = 2: points(5) = 2<br/>&nbsp;&nbsp;&nbsp; points(6) = 3: points(7) = 2<br/>&nbsp;&nbsp;&nbsp; points(8) = 4: points(9) = 4<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Create a lightweight Polyline object in model space<br/>&nbsp;&nbsp;&nbsp; Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)<br/>&nbsp;&nbsp;&nbsp; ZoomAll<br/>&nbsp;&nbsp;&nbsp; <br/>End Sub</p><p><br/>Sub Example_AddPolyline()<br/>&nbsp;&nbsp;&nbsp; ' This example creates a polyline in model space.<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim plineObj As AcadPolyline<br/>&nbsp;&nbsp;&nbsp; Dim points(0 To 14) As Double<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Define the 2D polyline points<br/>&nbsp;&nbsp;&nbsp; points(0) = 1: points(1) = 1: points(2) = 0<br/>&nbsp;&nbsp;&nbsp; points(3) = 1: points(4) = 2: points(5) = 0<br/>&nbsp;&nbsp;&nbsp; points(6) = 2: points(7) = 2: points(8) = 0<br/>&nbsp;&nbsp;&nbsp; points(9) = 3: points(10) = 2: points(11) = 0<br/>&nbsp;&nbsp;&nbsp; points(12) = 4: points(13) = 4: points(14) = 0<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Create a lightweight Polyline object in model space<br/>&nbsp;&nbsp;&nbsp; Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)<br/>&nbsp;&nbsp;&nbsp; ZoomAll<br/>&nbsp;&nbsp;&nbsp; <br/>End Sub</p>
页: [1]
查看完整版本: vba的一个多段线绘制问题