CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

GetKeyword Method (ActiveX)

2023-1-4 07:43| 发布者: admin| 查看: 525| 评论: 0|来自: AutoCAD

摘要: 从用户获取关键字字符串。

从用户获取关键字字符串。

支持的平台:仅窗口

签名

工 务 局:

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))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-12 07:25

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部