CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2022 开发者帮助

Rotate 方法 (ActiveX)

2024-5-18 18:44| 发布者: admin| 查看: 83| 评论: 0|原作者: admin|来自: AutoCAD

Rotate 方法 (ActiveX)

围绕基点旋转对象。

支持的平台:仅限 Windows

签名

VBA:

object.Rotate BasePoint, RotationAngle
对象

类型:所有绘图对象AttributeReference尺寸

此方法应用到的对象。

基点

访问:仅输入

类型:变体(双打的三元素阵列)

3D WCS 坐标指定旋转轴定义为平行于 UCS 的 Z 轴的点。

旋转角度

访问:仅输入

类型:

旋转物体的角度(以弧度为单位)。此角度决定了对象相对于其当前位置围绕基点旋转的距离。

返回值 (RetVal)

无返回值。

言论



例子

VBA:

Sub Example_Rotate()
    ' This example creates a lightweight polyline
    ' and then rotates that polyline.
    
    ' Create the polyline
    Dim plineObj As AcadLWPolyline
    Dim points(0 To 11) As Double
    points(0) = 1: points(1) = 2
    points(2) = 1: points(3) = 3
    points(4) = 2: points(5) = 3
    points(6) = 3: points(7) = 3
    points(8) = 4: points(9) = 4
    points(10) = 4: points(11) = 2
    Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
    plineObj.Closed = True
    ZoomAll
            
    MsgBox "Rotate the polyline by 45 degrees.", , "Rotate Example"
    
    ' Define the rotation
    Dim basePoint(0 To 2) As Double
    Dim rotationAngle As Double
    basePoint(0) = 4: basePoint(1) = 4.25: basePoint(2) = 0
    rotationAngle = 0.7853981   ' 45 degrees
    
    ' Rotate the polyline
    plineObj.Rotate basePoint, rotationAngle
    
    ZoomAll
    MsgBox "Rotation completed.", , "Rotate Example"
    
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_Rotate()
    ;; This example creates a lightweight polyline
    ;; and then rotates that polyline.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Create the polyline
    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 11)))
    (vlax-safearray-fill points '(1 1
                                  1 3
                                  2 3
                                  3 3
                                  4 4
                                  4 2
                                 )
    )

    (setq modelSpace (vla-get-ModelSpace doc))
    (setq plineObj (vla-AddLightWeightPolyline modelSpace points))
    (vla-put-Closed plineObj :vlax-true)
    (vla-ZoomAll acadObj)
            
    (alert "Rotate the polyline by 45 degrees.")
    
    ;; Define the rotation
    (setq basePoint (vlax-3d-point 4 4.25 0)
          rotationAngle 0.7853981)   ;; 45 degrees
    
    ;; Rotate the polyline
    (vla-Rotate plineObj basePoint rotationAngle)
    
    (vla-ZoomAll acadObj)
    (alert "Rotation completed.")
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1   苏公网安备32011402011833)

GMT+8, 2025-3-14 05:51

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部