CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2025 开发者帮助

Rotation 属性 (ActiveX)

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

Rotation 属性 (ActiveX)

指定对象的旋转角度。

支持的平台:仅限 Windows

属性值

只读:

类型:Double(ACAD_ANGLE 类型的 OLE 对象除外)

以弧度为单位的旋转角度。

言论

旋转角度相对于物体 WCS 的 X 轴,从 Z 轴向下看原点时,正角逆时针方向。

栅格:要以指定的旋转方式显示光栅图像,请将属性设置为 。ShowRotationTrue

文本:对于属性设置为 或 的文本,旋转角度是只读的。AlignmentacAlignmentAlignedacAlignmentFit



文本旋转角度



尺寸线角度

例子

VBA:

Sub Example_Rotation()
    ' This example creates a text object in model space.
    ' It then changes the Rotation of the text object.

    Dim textObj As AcadText
    Dim textString As String
    Dim insertionPoint(0 To 2) As Double
    Dim height As Double
    
    ' Define the text object
    textString = "Hello, World."
    insertionPoint(0) = 3: insertionPoint(1) = 3: insertionPoint(2) = 0
    height = 0.5
    
    ' Create the text object in model space
    Set textObj = ThisDrawing.ModelSpace.AddText(textString, insertionPoint, height)
    ZoomAll
    MsgBox "The Rotation is " & textObj.rotation, vbInformation, "Rotation Example"
    
    ' Change the value of the Rotation to 45 degrees (.707 radians)
    textObj.rotation = 0.707
    ZoomAll
    MsgBox "The Rotation is set to " & textObj.rotation, vbInformation, "Rotation Example"
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_Rotation()
    ;; This example creates a text object in model space.
    ;; It then changes the Rotation of the text object.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the text object
    (setq textString "Hello, World."
          insertionPoint (vlax-3d-point 3 3 0)
          height 0.5)

    ;; Create the text object in model space
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq textObj (vla-AddText modelSpace textString insertionPoint height))
    (vla-ZoomAll acadObj)

    (alert (strcat "The Rotation is " (rtos (vla-get-Rotation textObj) 2)))
    
    ;; Change the value of the Rotation to 45 degrees (.707 radians)
    (vla-put-Rotation textObj 0.707)
    (vla-ZoomAll acadObj)
    (alert (strcat "The Rotation is set to " (rtos (vla-get-Rotation textObj) 2)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2025-1-19 06:42

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部