CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2021 开发者帮助

GetOrientation 方法 (ActiveX)

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

GetOrientation 方法 (ActiveX)

获取指定的角度。忽略 ANGBASE 系统变量的设置。

支持的平台:仅限 Windows

签名

VBA:

RetVal = object.GetOrientation([Point [, Prompt]])
对象

类型: 实用程序

此方法应用到的对象。

访问:仅输入;自选

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

指定基点的 3D WCS 坐标。

提示

访问:仅输入;自选

类型:变体(字符串)

用于提示用户输入的文本。

返回值 (RetVal)

类型:

指定的角度。

言论

AutoCAD 暂停用户输入角度,并将返回值设置为所选角度的值。Point 参数指定 WCS 中的角度基点。Prompt 参数指定 AutoCAD 在暂停之前显示的字符串。“点”和“提示”都是可选的。

AutoCAD 用户可以通过在当前角度单位格式中输入数字来指定角度。用户还可以通过在图形屏幕上指定两个 2D 位置来指定角度。AutoCAD 从第一个点到当前十字准线位置绘制一条橡皮筋线,以帮助用户可视化角度。如果提供了“点”参数,AutoCAD 将使用此值作为两个点中的第一个点。角度在 WCS 的 XY 平面上测量(此方法忽略 PointZ 场)。角度增加的方向始终是逆时针方向。

无论使用何种方法指定角度,始终将返回值设置为以弧度表示的值。GetOrientation

此方法与该方法类似,但它忽略了存储在 ANGBASE 系统变量中的角度 0 的当前方向。使用的 0 角始终向右:“东”或“三点钟”。GetAngleGetOrientation

如果返回的是关键字而不是角度,AutoCAD 将生成错误消息“用户输入关键字”。使用该方法从返回值中获取关键字。GetInput

例子

VBA:

Sub Example_GetOrientation()
    ' This example uses the GetOrientation method to demonstrate three different ways to retrieve
    ' an orientation from the user.
    
    AppActivate ThisDrawing.Application.Caption
        
    Dim retOrientation As Double
    
    ' Return the Orientation in radians with a prompt
    retOrientation = ThisDrawing.Utility.GetOrientation(, "Enter an Orientation: ")
    MsgBox "The Orientation entered was " & retOrientation & vbCrLf & _
            "(Enter the next value without prompting.)", , "GetOrientation Example"
    
    ' Return the Orientation in radians without any prompt
    retOrientation = ThisDrawing.Utility.GetOrientation()
    MsgBox "The Orientation entered was " & retOrientation, , "GetOrientation Example"
    
    ' Return the Orientation in radians with a prompt and an Orientation base point
    Dim basePnt(0 To 2) As Double
    basePnt(0) = 2#: basePnt(1) = 2#: basePnt(2) = 0#
    retOrientation = ThisDrawing.Utility.GetOrientation(basePnt, "Enter an Orientation: ")
    MsgBox "The Orientation entered was " & retOrientation, , "GetOrientation Example"
        
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_GetOrientation()
    ;; This example uses the GetOrientation method to demonstrate three different ways to retrieve
    ;; an orientation from the user.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Return the Orientation in radians with a prompt
    (setq retOrientation (vla-GetOrientation (vla-get-Utility doc) nil "Enter an Orientation: "))
    (alert (strcat "The Orientation entered was " (rtos retOrientation 2) "\n"
                   "(Enter the next value without prompting.)"))

    ;; Return the Orientation in radians without any prompt
    (setq retOrientation (vla-GetOrientation (vla-get-Utility doc)))
    (alert (strcat "The Orientation entered was " (rtos retOrientation 2)))
    
    ;; Return the Orientation in radians with a prompt and an Orientation base point
    (setq basePnt (vlax-3d-point 2 2 0))
    (setq retOrientation (vla-GetOrientation (vla-get-Utility doc) basePnt "Enter an Orientation: "))
    (alert (strcat "The Orientation entered was " (rtos retOrientation 2)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

群   号:715888130

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

GMT+8, 2025-5-13 10:44

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部