GetAngle Method (ActiveX)

Gets the angle specified. Considers the setting of the ANGBASE system variable.

Supported platforms: Windows only

Signature

VBA:

RetVal = GetAngle([Point] [, Prompt])
object

Type: Utility

The object this method applies to.

Point

Access: Input-only; optional

Type: Variant (three-element array of doubles)

The 3D WCS coordinates specifying the first point.

Prompt

Access: Input-only; optional

Type: Variant (string)

The text used to prompt the user for input.

Return Value (RetVal)

Type: Double

The angle specified.

Remarks

AutoCAD pauses for user input of an angle and sets the return value to the value of the selected angle. The Point parameter specifies an angle base point in the two-dimensional WCS. The Prompt parameter specifies a string that AutoCAD displays before it pauses. Both Point and Prompt are optional.

The AutoCAD user can specify the angle by entering a number in the current angular units format. The user can set the angle also by specifying two 2D locations on the graphics screen. AutoCAD draws a rubber-band line from the first point to the current crosshair position to help the user visualize the angle. If the Point parameter is provided, AutoCAD uses this value as the first of the two points. The angle is measured in the XY plane of the WCS (GetAngle ignores the Z field of Point).

Regardless of the method used to specify the angle, GetAngle always sets the return value to a value expressed in radians. The direction of angular increase is always counterclockwise.

This function is almost identical to GetOrientation, but it takes into account the current value of the ANGBASE system variable. For GetOrientation, the zero angle is always to the right: "east" or "three o'clock." For GetAngle, the zero angle is the value of ANGBASE, which can be set to any of the four 90-degree quadrants. Both GetAngle and GetOrientation return a (real) angle value in radians measured counterclockwise from a base (zero) angle. For GetAngle, the base equals ANGBASE; for GetOrientation, the base is at the right. Both functions honor the current value of ANGDIR, which affects the value the user enters but not the value that these functions return.

User input (degrees) GetAngle returns GetOrientation returns
0 0.0 1.5708
-90 1.5708 3.14159
180 3.14159 4.71239
90 4.71239 0.0

You can use GetAngle to obtain a rotation amount for a block insertion, because an input of 0 degrees always returns 0 radians. You can use GetOrientation to obtain the baseline angle for a text entity to be aligned with other objects.

If a keyword is returned instead of an angle, AutoCAD will generate the error message "User input keyword." Use the GetInput method to obtain the keyword from the return value.

Examples

VBA:

Sub Example_GetAngle()
    ' This example demonstrates 4 different ways to retrieve
    ' an angle from the user using the GetAngle method.
    
    AppActivate ThisDrawing.Application.Caption

    Dim retAngle As Double
    
    ' Return the angle in radians with a prompt
    retAngle = ThisDrawing.Utility.GetAngle(, "Enter an angle: ")
    MsgBox "The angle entered was " & retAngle, , "GetAngle Example"
    
    ' Return the angle in radians without any prompt
    retAngle = ThisDrawing.Utility.GetAngle()
    MsgBox "The angle entered was " & retAngle, , "GetAngle Example"
    
    ' Return the angle in radians with a prompt and an angle base point
    Dim basePnt(0 To 2) As Double
    basePnt(0) = 2#: basePnt(1) = 2#: basePnt(2) = 0#
    retAngle = ThisDrawing.Utility.GetAngle(basePnt, "Enter an angle: ")
    MsgBox "The angle entered was " & retAngle, , "GetAngle Example"
    
    ' Return the angle in radians with an angle base point but no prompt
    retAngle = ThisDrawing.Utility.GetAngle(basePnt)
    MsgBox "The angle entered was " & retAngle, , "GetAngle Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_GetAngle()
    ;; This example demonstrates 4 different ways to retrieve
    ;; an angle from the user using the GetAngle method.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
      
    ;; Return the angle in radians with a prompt
    (setq retAngle (vla-GetAngle (vla-get-Utility doc) nil "\nEnter an angle: "))
    (alert (strcat "The angle entered was " (rtos retAngle 2)))
    
    ;; Return the angle in radians without any prompt
    (setq retAngle (vla-GetAngle (vla-get-Utility doc)))
    (alert (strcat "The angle entered was " (rtos retAngle 2)))
    
    ;; Return the angle in radians with a prompt and an angle base point
    (setq basePnt (vlax-3d-point 2 2 0))
    (setq retAngle (vla-GetAngle (vla-get-Utility doc) basePnt "\nEnter an angle: "))
    (alert (strcat "The angle entered was " (rtos retAngle 2)))
    
    ;; Return the angle in radians with an angle base point but no prompt
    (setq retAngle (vla-GetAngle (vla-get-Utility doc) basePnt))
    (alert (strcat "The angle entered was " (rtos retAngle 2)))
)