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