AutoCAD で選択された点を取得します。
サポートされているプラットフォーム: Windows のみ
VBA:
RetVal = object.GetPoint([Point [, Prompt]])
タイプ: Utility
このメソッドが適用されるオブジェクト。
アクセス: 入力のみ; オプション
タイプ: バリアント型(3 要素の倍精度浮動小数点数型配列)
相対基点を指定する 3D WCS 座標。
アクセス: 入力のみ; オプション
タイプ: バリアント型(文字列)
ユーザに入力を求めるときに表示される文字列。
タイプ: バリアント型(3 要素の倍精度浮動小数点数型配列)
AutoCAD ユーザが選択した点の 3D WCS 座標。
AutoCAD は、ユーザが点を入力するのを待って、選択された点の値に対する戻り値を設定します。パラメータ Point は、相対基点を示す WCS を指定します。パラメータ Prompt は、ユーザ入力を求める際に AutoCAD が表示する文字列を指定します。Point および Prompt はオプションです。
AutoCAD ユーザは、現在の単位形式で座標を入力すれば、点を指定することができます。GetPoint メソッドでは、パラメータ Point と戻り値は 3 次元の点として扱われます。また、グラフィックス画面上で位置を指定して、点を指定することもできます。パラメータ Point が与えられている場合は、AutoCAD によって Point から現在のクロスヘア カーソルの位置までのラバーバンド線が描かれます。
戻り値に格納される点の座標は、WCS で示されます。
点ではなくキーワードが返された場合は、「ユーザ入力がキーワードです」というエラー メッセージが表示されます。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
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)
)