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

把xy平面上的polyline转到zy平面去

<P>先用下面例程生成polyline</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>然后用下面的例程旋转</P>
<P>Sub getpolyline()</P>
<P>&nbsp;&nbsp;&nbsp; Dim UserMessage As String<BR>&nbsp;&nbsp;&nbsp; Dim ControlPoints As Variant<BR>&nbsp;&nbsp;&nbsp; Dim iCount As Long, iPoint As Integer<BR>&nbsp;&nbsp;&nbsp; <BR>&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<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Dim retCoord As Variant<BR>&nbsp;&nbsp;&nbsp; Dim points(200) As Double<BR>&nbsp;&nbsp;&nbsp; Dim coord As Variant<BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Dim polyObj As Acad3DPolyline<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; <BR>&nbsp; n = ThisDrawing.ModelSpace.Count<BR>&nbsp; 'MsgBox "N = " &amp; Str(n)<BR>&nbsp; <BR>&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; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mynpoint = (UBound(newObjs.Coordinates) + 1) / 2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For J = 0 To mynpoint - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; coord = newObjs.Coordinate(J)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; points(3 * J) = 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; points(3 * J + 1) = coord(1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; points(3 * J + 2) = coord(0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next J<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Create a 3DPolyline in model space<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set polyObj = ThisDrawing.ModelSpace.Add3DPoly(points)<BR>&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; <BR>&nbsp; MsgBox "Good on ya!"</P>
<P>End Sub</P>
<P>问题是转完了老有一条连接polyline最后定点与坐标原点的连线。问题在那?</P>
<P>我觉得是生成3dpolyline时,定点points数组的大小定义的有多余的空间。该怎么解决呢?</P>

pzhlmp 发表于 2006-11-12 23:34:00

有用,顶一下。

shirazbj 发表于 2006-11-13 17:54:00

<P>现在发现用rotate3d命令也可以。</P>

tcsl9621 发表于 2006-11-13 22:49:00

就是用rotate3d命令。
页: [1]
查看完整版本: 把xy平面上的polyline转到zy平面去