GetKeyword 方法 (ActiveX)
从用户获取关键字字符串。 支持的平台:仅限 Windows 签名VBA: RetVal = object.GetKeyword([Prompt])
返回值 (RetVal)类型:字符串 从用户返回的关键字。 言论AutoCAD 暂停用户输入关键字,并将返回值设置为输入的关键字。Prompt 参数指定 AutoCAD 在暂停之前显示的字符串。提示是可选的。返回值的最大长度为 511 个字符。 AutoCAD 用户可以从键盘输入关键字。此方法将接受的关键字列表由对该方法的先前调用设置。如果用户输入的字符串未在调用 中指定,AutoCAD 将显示错误消息并重试(如果指定了提示,则重新显示提示)。如果用户未输入任何内容,但按 Enter 键,则返回空字符串 (“”),除非调用也不允许输入。InitializeUserInputInitializeUserInputGetKeywordInitializeUserInputNULL 例子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
可视化 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-10-30 07:09
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.