获取与提示行或屏幕上一组选定点的距离。 支持的平台:仅窗口 签名工 务 局: RetVal = object.GetDistance([Point [, Prompt]])
返回值(RetVal)类型:变体(双精度或双精度数组) 与提示线或屏幕上一组选定点的距离。 言论AutoCAD 会暂停用户输入线性距离,并将返回值设置为所选距离的值。Point参数指定 WCS 坐标中的基点。提示参数指定 AutoCAD 在暂停之前显示的字符串。“点”和“提示”都是可选的。 AutoCAD 用户可以通过输入当前单位格式的数字来指定距离。用户还可以通过在图形屏幕上指定两个位置来设置距离。AutoCAD 绘制一条从第一个点到当前十字准线位置的橡皮筋线,以帮助用户可视化距离。如果提供了“点”参数,AutoCAD 将使用此值作为两个点中的第一个。 默认情况下,将Point和返回值视为三维点。对方法的先前调用可以强制Point为二维,从而确保此方法返回平面距离。GetDistanceInitializeUserInput 无论用于指定距离或当前线性单位(例如,英尺和英寸)的方法如何,此方法始终将返回值设置为双精度浮点值。 例子工 务 局: 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
Visual 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-10-28 22:51
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.