GetAngle 方法 (ActiveX)
获取指定的角度。考虑 ANGBASE 系统变量的设置。 支持的平台:仅限 Windows 签名VBA: RetVal = GetAngle([Point] [, Prompt])
返回值 (RetVal)类型:双 指定的角度。 言论AutoCAD 暂停用户输入角度,并将返回值设置为所选角度的值。Point 参数指定二维 WCS 中的角度基点。Prompt 参数指定 AutoCAD 在暂停之前显示的字符串。“点”和“提示”都是可选的。 AutoCAD 用户可以通过在当前角度单位格式中输入数字来指定角度。用户还可以通过在图形屏幕上指定两个 2D 位置来设置角度。AutoCAD 绘制一条从第一个点到当前十字准线位置的橡皮筋线,以帮助用户可视化角度。如果提供了“点”参数,AutoCAD 将使用此值作为两个点中的第一个点。角度在 WCS 的 XY 平面上测量(忽略 Point 的 Z 场)。GetAngle 无论使用何种方法指定角度,始终将返回值设置为以弧度表示的值。角度增加的方向始终是逆时针方向。GetAngle 此函数几乎与 相同,但它考虑了 ANGBASE 系统变量的当前值。因为 ,零角总是向右:“东”或“三点钟”。对于 ,零角是 ANGBASE 的值,可以设置为四个 90 度象限中的任何一个。两者都返回一个(以弧度为单位)的(实际)角度值,从基本(零)角度逆时针测量。对于 ,基数等于 ANGBASE;对于 ,底座位于右侧。这两个函数都遵循 ANGDIR 的当前值,这会影响用户输入的值,但不影响这些函数返回的值。GetOrientationGetOrientationGetAngleGetAngleGetOrientationGetAngleGetOrientation
您可以使用来获取块插入的旋转量,因为 0 度的输入始终返回 0 弧度。可用于获取要与其他对象对齐的文本图元的基线角度。GetAngleGetOrientation 如果返回的是关键字而不是角度,AutoCAD 将生成错误消息“用户输入关键字”。使用该方法从返回值中获取关键字。GetInput 例子VBA: Sub Example_GetAngle() ' This example demonstrates 4 different ways to retrieve ' an angle from the user using the GetAngle method. AppActivate ThisDrawing.Application.Caption Dim retAngle As Double ' Return the angle in radians with a prompt retAngle = ThisDrawing.Utility.GetAngle(, "Enter an angle: ") MsgBox "The angle entered was " & retAngle, , "GetAngle Example" ' Return the angle in radians without any prompt retAngle = ThisDrawing.Utility.GetAngle() MsgBox "The angle entered was " & retAngle, , "GetAngle Example" ' Return the angle in radians with a prompt and an angle base point Dim basePnt(0 To 2) As Double basePnt(0) = 2#: basePnt(1) = 2#: basePnt(2) = 0# retAngle = ThisDrawing.Utility.GetAngle(basePnt, "Enter an angle: ") MsgBox "The angle entered was " & retAngle, , "GetAngle Example" ' Return the angle in radians with an angle base point but no prompt retAngle = ThisDrawing.Utility.GetAngle(basePnt) MsgBox "The angle entered was " & retAngle, , "GetAngle Example" End Sub 可视化 LISP: (vl-load-com) (defun c:Example_GetAngle() ;; This example demonstrates 4 different ways to retrieve ;; an angle from the user using the GetAngle method. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) ;; Return the angle in radians with a prompt (setq retAngle (vla-GetAngle (vla-get-Utility doc) nil "\nEnter an angle: ")) (alert (strcat "The angle entered was " (rtos retAngle 2))) ;; Return the angle in radians without any prompt (setq retAngle (vla-GetAngle (vla-get-Utility doc))) (alert (strcat "The angle entered was " (rtos retAngle 2))) ;; Return the angle in radians with a prompt and an angle base point (setq basePnt (vlax-3d-point 2 2 0)) (setq retAngle (vla-GetAngle (vla-get-Utility doc) basePnt "\nEnter an angle: ")) (alert (strcat "The angle entered was " (rtos retAngle 2))) ;; Return the angle in radians with an angle base point but no prompt (setq retAngle (vla-GetAngle (vla-get-Utility doc) basePnt)) (alert (strcat "The angle entered was " (rtos retAngle 2))) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-19 06:42
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.