ユーザからキーワード文字列を取得します。
サポートされているプラットフォーム: Windows のみ
VBA:
RetVal = object.GetKeyword([Prompt])
タイプ: Utility
このメソッドが適用されるオブジェクト。
アクセス: 入力のみ; オプション
タイプ: バリアント型(文字列)
ユーザに入力を求めるときに表示される文字列。
タイプ: 文字列
ユーザから返されるキーワード
AutoCAD は、ユーザがキーワードを入力するのを待って、入力されたキーワードを戻り値を設定します。パラメータ Prompt は、ユーザ入力を求める際に AutoCAD が表示する文字列を指定します。Prompt は、オプションです。戻り値の最大長は、511 文字です。
ユーザは、キーボードからキーワードを入力します。このメソッドが受け取るキーワードのリストは、あらかじめ InitializeUserInput メソッドを呼び出して設定しておきます。InitializeUserInput メソッドの呼び出し時に指定されなかった文字列をユーザが入力した場合、エラー メッセージが表示され、やり直しを求めます(プロンプト文字列が指定されている場合には、それを再び表示します)。ユーザがただ[Enter]を押しただけの場合は、InitializeUserInput メソッドの呼び出しで、NULL 入力が認められていない場合を除いて、GetKeyword メソッドは空の文字列(" ")を返します。
VBA:
Sub Example_GetKeyword()
' This example uses Getkeyword to return a keyword entered by the user.
' InitializeUserInput establishes the valid keywords.
AppActivate ThisDrawing.Application.Caption
' Define the list of valid keywords
Dim kwordList As String
kwordList = "Width Height Depth"
ThisDrawing.Utility.InitializeUserInput 1, kwordList
' Prompt the user to input any of the keywords. Return "Width", "Height" or "Depth" in
' the returnString variable depending on whether the user input "W", "H" or "D".
Dim returnString As String
returnString = ThisDrawing.Utility.GetKeyword(vbLf & "Enter a keyword [Height/Width/Depth]: ")
MsgBox "You entered " & returnString, , "GetKeyword Example"
End Sub
Visual LISP:
(vl-load-com)
(defun c:Example_GetKeyword()
;; This example uses Getkeyword to return a keyword entered by the user.
;; InitializeUserInput establishes the valid keywords.
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
;; Define the list of valid keywords
(setq kwordList "Width Height Depth")
(vla-InitializeUserInput (vla-get-Utility doc) 1 kwordList)
;; Prompt the user to input any of the keywords. Return "Width", "Height" or "Depth" in
;; the returnString variable depending on whether the user input "W", "H" or "D".
(setq returnString (vla-GetKeyword (vla-get-Utility doc) "\nEnter a keyword [Height/Width/Depth]: "))
(alert (strcat "You entered " returnString))
)