GetInput 方法 (ActiveX)
将用户的输入字符串转换为关键字索引。 支持的平台:仅限 Windows 返回值 (RetVal)类型:字符串 指定输入关键字的索引。 言论此方法检索 AutoCAD 用户在调用其中一个用户输入函数( 方法)期间输入的关键字。Get* 关键字的最大长度为 511 个字符(第 512 个字符保留给该字符)。NULL 对的调用是没有意义的,除非它紧随对用户输入函数之一的调用之后,否则将失败。即便如此,只有当用户输入函数返回错误描述“用户输入是关键字”时,调用才会成功。GetInput 无需在调用方法后调用。GetInputGetKeyword 应用程序识别的关键字由对方法的先前调用指定。关键字的解释完全取决于应用程序。关键字不应与AutoCAD命令的名称重复。InitializeUserInput 用户可以缩写关键字,但始终返回在调用中使用原始大写定义的完整关键字,因此应用程序只需对其定义的每个关键字进行一个字符串比较。GetInputInitializeUserInput 例子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 可视化 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))) ) ) ) |
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-3-31 13:47
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.