GetDistance 方法 (ActiveX)
获取与提示线或屏幕上选定的一组点的距离。 支持的平台:仅限 Windows 签名VBA: RetVal = object.GetDistance([Point [, Prompt]])
返回值 (RetVal)类型:变体(双精度或双精度数组) 与屏幕上的提示线或一组选定点的距离。 言论AutoCAD 暂停用户输入线性距离,并将返回值设置为选定距离的值。Point 参数指定 WCS 坐标中的基点。Prompt 参数指定 AutoCAD 在暂停之前显示的字符串。“点”和“提示”都是可选的。 AutoCAD 用户可以通过以当前单位格式输入数字来指定距离。用户还可以通过在图形屏幕上指定两个位置来设置距离。AutoCAD 绘制从第一个点到当前十字准线位置的橡皮筋线,以帮助用户可视化距离。如果提供了“点”参数,AutoCAD 将使用此值作为两个点中的第一个点。 默认情况下,将 Point 和返回值视为三维点。对该方法的先前调用可以强制 Point 为二维,从而确保此方法返回平面距离。GetDistanceInitializeUserInput 无论使用何种方法指定距离或当前线性单位(例如,英尺和英寸),此方法始终将返回值设置为双精度浮点值。 例子VBA: Sub Example_GetDistance() ' This example returns the distance entered by the user. AppActivate ThisDrawing.Application.Caption Dim returnDist As Double Dim basePnt(0 To 2) As Double basePnt(0) = 0#: basePnt(1) = 0#: basePnt(2) = 0# ' Return the value entered by user. A prompt is provided. returnDist = ThisDrawing.Utility.GetDistance(, "Enter distance: ") MsgBox "The distance entered was " & returnDist & vbCrLf & _ "(Enter the next value without prompting.)", , "GetDistance Example" ' Return the value entered by user. No prompt is provided. returnDist = ThisDrawing.Utility.GetDistance() MsgBox "The distance entered was " & returnDist, , "GetDistance Example" ' Return the value entered by user. A base point and prompt are provided. returnDist = ThisDrawing.Utility.GetDistance(basePnt, "Enter a distance: ") MsgBox "The distance entered was " & returnDist, , "GetDistance Example" End Sub 可视化 LISP: (vl-load-com) (defun c:Example_GetDistance() ;; This example returns the distance entered by the user. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) ;; Return the value entered by user. A prompt is provided. (setq returnDist (vla-GetDistance (vla-get-Utility doc) nil "Enter distance: ")) (alert (strcat "The distance entered was " (rtos returnDist 2) "\n" "(Enter the next value without prompting.)")) ;; Return the value entered by user. No prompt is provided. (setq returnDist (vla-GetDistance (vla-get-Utility doc))) (alert (strcat "The distance entered was " (rtos returnDist 2))) ;; Return the value entered by user. A base point and prompt are provided. (setq basePnt (vlax-3d-point 0 0 0)) (setq returnDist (vla-GetDistance (vla-get-Utility doc) basePnt "Enter a distance: ")) (alert (strcat "The distance entered was " (rtos returnDist 2))) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-19 06:51
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.