CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

GetDistance Method (ActiveX)

2023-1-4 08:33| 发布者: admin| 查看: 499| 评论: 0|来自: AutoCAD

摘要: 获取与提示行或屏幕上一组选定点的距离。

获取与提示行或屏幕上一组选定点的距离。

支持的平台:仅窗口

签名

工 务 局:

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

类型:实用工具

此方法适用的对象。

访问:仅输入;自选

类型:变体(双精度的三元素数组)

指定基点的 3D WCS 坐标。如果未提供此点,则用户必须输入两个点。

提示

访问:仅输入;自选

类型:变体(字符串)

要显示以提示用户输入的文本。

返回值(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)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 13:38

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部