InitializeUserInput Method (ActiveX)

Initializes the GetKeyword method.

Supported platforms: Windows only

Signature

VBA:

object.InitializeUserInput Bits [, Keyword]
object

Type: Utility

The object this method applies to.

Bits

Access: Input-only

Type: Integer

To set more than one condition at a time, add the values together in any combination. If this value is not included or is set to 0, none of the control conditions apply.

  • 1: Disallows NULL input. This prevents the user from responding to the request by entering only [Return] or a space.
  • 2: Disallows input of zero (0). This prevents the user from responding to the request by entering 0.
  • 4: Disallows negative values. This prevents the user from responding to the request by entering a negative value.
  • 8: Does not check drawing limits, even if the LIMCHECK system variable is on. This enables the user to enter a point outside the current drawing limits. This condition applies to the next user-input function even if the AutoCAD LIMCHECK system variable is currently set.
  • 16: Not currently used.
  • 32: Uses dashed lines when drawing rubber-band lines or boxes. This causes the rubber-band line or box that AutoCAD displays to be dashed instead of solid, for those methods that let the user specify a point by selecting a location on the graphics screen. (Some display drivers use a distinctive color instead of dashed lines.) If the AutoCAD POPUPS system variable is 0, AutoCAD ignores this bit.
  • 64: Ignores Z coordinate of 3D points (GetDistance method only). This option ignores the Z coordinate of 3D points returned by the GetDistance method, so an application can ensure this function returns a 2D distance.
  • 128: Allows arbitrary input—whatever the user types.
Keyword

Access: Input-only; optional

Type: Variant (array of strings)

The keywords that the following user-input method will recognize.

Return Value (RetVal)

No return value.

Remarks

Keywords must be defined with this method before the call to GetKeyword. Certain user-input methods can accept keyword values in addition to the values they normally return, provided that this method has been called to define the keyword. The user-input methods that can accept keywords are: GetKeyword, GetInteger, GetReal, GetDistance, GetAngle, GetOrientation, GetPoint, and GetCorner.

Examples

VBA:

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