CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

GetPoint Method (ActiveX)

2023-1-4 07:12| 发布者: admin| 查看: 670| 评论: 0|来自: AutoCAD

摘要: 获取在 AutoCAD 中选择的点。

获取在 AutoCAD 中选择的点。

支持的平台:仅窗口

签名

工 务 局:

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

类型:实用工具

此方法适用的对象。

访问:仅输入;自选

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

指定相对基点的 3D WCS 坐标。

提示

访问:仅输入;自选

类型:变体(字符串)

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

返回值(RetVal)

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

AutoCAD 用户所选择的点的三维 WCS 坐标。

言论

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

AutoCAD 用户可以通过输入当前单位格式的坐标来指定点;将点参数和返回值视为三维。用户还可以通过在图形屏幕上指定位置来指定点。如果提供了“点”参数,AutoCAD 将绘制一条从“点”到当前十字准线位置的橡皮筋线。GetPoint

返回值中存储的点的坐标以 WCS 表示。

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

例子

工 务 局:

Sub Example_GetPoint()
    ' This example returns a point entered by the user.
    
    AppActivate ThisDrawing.Application.Caption
    
    Dim returnPnt As Variant
    
    ' Return a point using a prompt
    returnPnt = ThisDrawing.Utility.GetPoint(, "Enter a point: ")
    MsgBox "The WCS of the point is: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2) & vbCrLf & _
           "(Enter the next value without prompting.)", , "GetPoint Example"
    
    ' Return a point, no prompt
    returnPnt = ThisDrawing.Utility.GetPoint
    MsgBox "The WCS of the point is: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2), , "GetPoint Example"
    
    ' Return a point using a base point and a prompt
    Dim basePnt(0 To 2) As Double
    basePnt(0) = 2#: basePnt(1) = 2#: basePnt(2) = 0#
    returnPnt = ThisDrawing.Utility.GetPoint(basePnt, "Enter a point: ")
    MsgBox "The WCS of the point is: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2)
    
    ' Create a line from the base point and the last point entered
    Dim lineObj As AcadLine
    Set lineObj = ThisDrawing.ModelSpace.AddLine(basePnt, returnPnt)
    ZoomAll
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_GetPoint()
    ;; This example returns a point entered by the user.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Return a point using a prompt
    (setq returnPnt (vlax-variant-value (vla-GetPoint (vla-get-Utility doc) nil "Enter a point: ")))
    (alert (strcat "The WCS of the point is: " (rtos (vlax-safearray-get-element returnPnt 0) 2) ", "
		                                             (rtos (vlax-safearray-get-element returnPnt 1) 2) ", "
		                                             (rtos (vlax-safearray-get-element returnPnt 2) 2) "\n"
                                               "(Enter the next value without prompting.)"))
    
    ;; Return a point, no prompt
    (setq returnPnt (vlax-variant-value (vla-GetPoint (vla-get-Utility doc))))
    (alert (strcat "The WCS of the point is: " (rtos (vlax-safearray-get-element returnPnt 0) 2) ", "
		                                             (rtos (vlax-safearray-get-element returnPnt 1) 2) ", "
		                                             (rtos (vlax-safearray-get-element returnPnt 2) 2)))
    
    ;; Return a point using a base point and a prompt
    (setq basePnt (vlax-3d-point 2 2 0))
    (setq returnPnt (vlax-variant-value (vla-GetPoint (vla-get-Utility doc) basePnt "Enter a point: ")))
    (alert (strcat "The WCS of the point is: " (rtos (vlax-safearray-get-element returnPnt 0) 2) ", "
		                                             (rtos (vlax-safearray-get-element returnPnt 1) 2) ", "
		                                             (rtos (vlax-safearray-get-element returnPnt 2) 2)))
    
    ;; Create a line from the base point and the last point entered
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq lineObj (vla-AddLine modelSpace basePnt returnPnt))
    (vla-ZoomAll acadObj)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-19 14:29

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部