CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

初始化用户输入方法 (ActiveX)

2023-1-4 06:08| 发布者: admin| 查看: 758| 评论: 0|来自: AutoCAD

摘要: 初始化 GetKeyword 方法。

初始化 GetKeyword 方法。

支持的平台:仅窗口

签名

工 务 局:

object.InitializeUserInput Bits [, Keyword]
对象

类型:实用工具

此方法适用的对象。

访问:仅输入

类型:整数

要一次设置多个条件,请将这些值以任意组合相加。如果未包含此值或将其设置为 0,则任何控制条件都不适用。

  • 1:不允许空输入。这会阻止用户通过仅输入 [Return] 或空格来响应请求。
  • 2:不允许输入零 (0)。这会阻止用户通过输入 0 来响应请求。
  • 4:不允许负值。这可以防止用户通过输入负值来响应请求。
  • 8:不检查绘图限制,即使 LIMCHECK 系统变量处于打开状态。这使用户能够输入当前绘图限制之外的点。即使当前设置了 AutoCAD LIMCHECK 系统变量,此条件也适用于下一个用户输入函数。
  • 16:当前未使用。
  • 32:绘制橡皮筋线或框时使用虚线。这会导致 AutoCAD 显示的橡皮筋线或框变为虚线而不是实线,因为这些方法允许用户通过在图形屏幕上选择位置来指定点。(某些显示驱动程序使用独特的颜色而不是虚线。如果 AutoCAD 弹出窗口系统变量为 0,则 AutoCAD 将忽略此位。
  • 64:忽略 3D 点的Z坐标(仅限方法)。此选项忽略该方法返回的 3D 点的 Z 坐标,因此应用程序可以确保此函数返回 2D 距离。GetDistanceGetDistance
  • 128:允许任意输入 - 无论用户键入什么。
关键词

访问:仅输入;自选

类型:变体(字符串数组)

以下用户输入法将识别的关键字。

返回值(RetVal)

无返回值。

言论

在调用 to 之前,必须使用此方法定义关键字。某些用户输入法除了通常返回的值之外,还可以接受关键字值,前提是已调用此方法来定义关键字。可以接受关键字的用户输入方法是:,,,,,,,和。GetKeywordGetKeywordGetIntegerGetRealGetDistanceGetAngleGetOrientationGetPointGetCorner

例子

工 务 局:

Sub Example_InitializeUserInput()
    ' 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_InitializeUserInput()
    ;; This example prompts for user input of a point. By using the
    ;; InitializeUserInput method to define a keyword list, it 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)))
	)
    )
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-11 14:21

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部