从用户获取关键字字符串。 支持的平台:仅窗口 签名工 务 局: RetVal = object.GetKeyword([Prompt])
返回值(RetVal)类型:字符串 从用户返回的关键字。 言论AutoCAD 为用户输入关键字而暂停,并将返回值设置为输入的关键字。提示参数指定 AutoCAD 在暂停之前显示的字符串。提示是可选的。返回值的最大长度为 511 个字符。 AutoCAD 用户可以从键盘输入关键字。此方法将接受的关键字列表由对该方法的先前调用设置。如果用户输入的字符串未在调用中指定,AutoCAD 将显示一条错误消息并重试(如果指定了提示,则重新显示提示)。如果用户未输入任何内容,而是按 Enter 键,则返回空字符串 (“”),除非调用 to 也不允许输入。InitializeUserInputInitializeUserInputGetKeywordInitializeUserInputNULL 例子工 务 局: 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)) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:22
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.