ユーザからの入力文字列をキーワード インデックスに変換します。
サポートされているプラットフォーム: Windows のみ
タイプ: 文字列
どのキーワードが入力されたかを指定するインデックス
このメソッドは、ユーザ入力関数(Get* メソッド)を呼び出している間に、AutoCAD ユーザによって入力されたキーワードを取り出します。
キーワードの最大長は 511 文字です(512 番目の文字は NULL 文字のために予約されています)。
GetInput メソッドの呼び出しは意味がなく、直前にユーザ入力関数の呼び出しがなければ異常終了します。ユーザ入力関数を呼び出した場合でも、「ユーザ入力がキーワードです」というエラー メッセージが返されたときのみ正常終了します。
GetKeyword メソッドを呼び出した後で、GetInput メソッドを呼び出す必要はありません。
アプリケーションによって認識されるキーワードは、直前の InitializeUserInput メソッドの呼び出しで指定されます。キーワードの解釈はアプリケーションに任されています。キーワードが、AutoCAD コマンド名と重複しないようにしてください。
ユーザはキーワードを短縮して入力することができますが、GetInput メソッドは、InitializeUserInput メソッドの呼び出しで定義された表記のままの完全なキーワードを返します。したがって、アプリケーションはキーワードごとに 1 つの文字列を比較するだけですみます。
VBA:
Sub Example_GetInput()
' This example prompts for user input of a point. By using the
' InitializeUserInput method to define a keyword list, the example can also
' return keywords entered by the user.
AppActivate ThisDrawing.Application.Caption
On Error Resume Next
' Define the valid keywords
Dim keywordList As String
keywordList = "Line Circle"
' Call InitializeUserInput to set up the keywords
ThisDrawing.Utility.InitializeUserInput 128, keywordList
' Get the user input
Dim returnPnt As Variant
returnPnt = ThisDrawing.Utility.GetPoint(, vbLf & "Enter a point [Line/Circle]: ")
If Err Then
If StrComp(Err.Description, "User input is a keyword", 1) = 0 Then
' One of the keywords was entered
Dim inputString As String
Err.Clear
inputString = ThisDrawing.Utility.GetInput
MsgBox "You entered the keyword: " & inputString
Else
MsgBox "Error selecting the point: " & Err.Description
Err.Clear
End If
Else
' Display point coordinates
MsgBox "The WCS of the point is: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2), , "GetInput Example"
End If
End Sub
Visual LISP:
(vl-load-com)
(defun c:Example_GetInput()
;; This example prompts for user input of a point. By using the
;; InitializeUserInput method to define a keyword list, the example can also
;; return keywords entered by the user.
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
;; Define the valid keywords
(setq keywordList "Line Circle")
;; Call InitializeUserInput to set up the keywords
(vla-InitializeUserInput (vla-get-Utility doc) 128 keywordList)
;; Get the user input
(setq returnPntOrErr (vl-catch-all-apply 'vla-GetPoint (list (vla-get-Utility doc) nil "Enter a point [Line/Circle]: ")))
(if (= (type returnPntOrErr)'VL-CATCH-ALL-APPLY-ERROR)
(progn
(if (= (vl-catch-all-error-message returnPntOrErr) "Automation Error. User input is a keyword")
(progn
(setq inputString (vla-GetInput (vla-get-Utility doc)))
(alert (strcat "You entered the keyword: " inputString))
)
(alert "User pressed ESC or unknown input was provided.")
)
)
;; Display point coordinates
(progn
(setq returnPnt (vlax-safearray->list (vlax-variant-value returnPntOrErr)))
(alert (strcat "The WCS of the point is: " (rtos (nth 0 returnPnt) 2) ", " (rtos (nth 1 returnPnt) 2) ", " (rtos (nth 2 returnPnt) 2)))
)
)
)