shirazbj 发表于 2006-11-4 10:53:00

如何知道一条polyline有多少点呀?

<P>Sub getpolyline()</P>
<P>&nbsp;&nbsp;&nbsp; Dim i, n As Integer<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; 'Dim newObjs As AcadPolyline<BR>&nbsp;&nbsp;&nbsp; Dim newObjs As AcadLWPolyline&nbsp;&nbsp; 'Object drawed by pline command under version 2006<BR></P>
<P>&nbsp;&nbsp;&nbsp; Dim retCoord As Variant<BR>&nbsp;&nbsp;&nbsp; Dim points(500) As Double</P>
<P>&nbsp; <BR>&nbsp; n = ThisDrawing.ModelSpace.Count<BR></P>
<P>&nbsp; For i = 0 To n - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If ThisDrawing.ModelSpace.Item(i).ObjectName = "AcDbPolyline" Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set newObjs = ThisDrawing.ModelSpace.Item(i)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'newObjs怎么老是空的?下面的结果老不对</P>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Return all the coordinates of the polyline<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; retCoord = newObjs.Coordinates<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mynpoint = (UBound(retCoord) + 1) / 3<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '.......</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; Next i<BR>&nbsp;&nbsp;<BR>&nbsp; MsgBox "Good on ya!"<BR>&nbsp;<BR>End Sub</P>

shirazbj 发表于 2006-11-4 11:42:00

把mynpoint = (UBound(retCoord) + 1) / 3中的除3改成除2,结果好像对了。我还以为定点存的是x,y,z三个坐标呢。3dpoly应该是x,y,z了吧。
页: [1]
查看完整版本: 如何知道一条polyline有多少点呀?