明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1552|回复: 3

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

[复制链接]
发表于 2006-11-4 13:00:00 | 显示全部楼层 |阅读模式

先用下面例程生成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数组的大小定义的有多余的空间。该怎么解决呢?

发表于 2006-11-12 23:34:00 | 显示全部楼层
有用,顶一下。
 楼主| 发表于 2006-11-13 17:54:00 | 显示全部楼层

现在发现用rotate3d命令也可以。

发表于 2006-11-13 22:49:00 | 显示全部楼层
就是用rotate3d命令。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 20:40 , Processed in 0.156017 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表