GetPoint 方法 (ActiveX)
获取在AutoCAD中选定的点。 支持的平台:仅限 Windows 签名VBA: RetVal = object.GetPoint([Point [, Prompt]])
返回值 (RetVal)类型:变体(双打的三元素阵列) AutoCAD 用户所选点的三维 WCS 坐标。 言论AutoCAD 暂停用户输入点,并将返回值设置为选定点的值。Point 参数指定 WCS 中的相对基点。Prompt 参数指定 AutoCAD 在暂停之前显示的字符串。“点”和“提示”都是可选的。 AutoCAD 用户可以通过以当前单位格式输入坐标来指定点; 将 Point 参数和返回值视为三维点。用户也可以通过在图形屏幕上指定位置来指定该点。如果提供了“点”参数,AutoCAD 将绘制一条从“点”到当前十字准线位置的橡皮筋线。GetPoint 存储在返回值中的点的坐标以 WCS 表示。 如果返回的是关键字而不是点,AutoCAD 将生成错误消息“用户输入关键字”。使用该方法从返回值中获取关键字。GetInput 例子VBA: 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 可视化 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) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-15 22:26
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.