Angles in AutoLISP with autolisp in AutoCAD

If you are using angles other than the default measured counter-clockwise from the positive X-axis, you will need to know the difference between two related commands: (getangle) and (getorient).

  • The (getangle) function measures with the zero-angle at the current base angle setting in the Units dialog (system variable ANGBASE).
  • The (getorient) function always measures with the zero-angle to the right (east, or positive X-axis), regardless of the ANGBASE setting.
  • The system variable ANGBASE controls the zero (0) direction for angles. By default it is set to 0, the positive X-axis. If you set it to 90 then zero will be north or the positive Y-axis. You can use any angle.
  • The system variable ANGDIR controls the angle direction: 0 for counter-clockwise (the default) or 1 for clockwise.

Explanation: the (getangle) and (getorient) functions

(getangle [point] [prompt])
(getorient [point] [prompt])

The optional [point] lets you include a point (usually a symbol that points back to information that gives you a point) that defines the first point of the angle. The optional [prompt] allows you to prompt the user.

Both these functions return a real number representing the value in radians of an angle entered either by pointing or by typing a value.

Examples

  • All replies are in radians.
See also  Every List is Evaluated in the Same Specific Manner in Autolisp

When ANGBASE and ANGDIR are set to the AutoCAD default, both functions give you the same information:
Command: (getangle)
135
2.35619                      135 degrees
Command: (getorient)

135
2.35619                        135 degrees

Changing the system variable ANGBASE to 90 (North or Y-axis) results in:

Command: (getangle)
135
2.35619                      135 degrees, based on current ANGBASE
Command: (getorient)

135
3.92699                      225 degrees, based on default ANGBASE

Further changing the system variable ANGDIR to clockwise (1) results in:
Command: (getangle)
135
3.92699                       225 degrees, based on current ANGBASE
Command: (getorient)

135
5.49779                          315 degrees, based on default ANGBASE

  • The angle input by the user is based on the current ANGDIR, but both (getangle) and (getorient) ignore ANGDIR in the value returned.
  • If ANGBASE is set to 90, using (getangle) for BLOCK insertions will allow an input of 0 to equal 0.
  • If ANGBASE is set to 90, using (getorient) for TEXT insertions will allow an input of 0 to insert text along the X-axis.
See also  Converting Data Types with autolisp in AutoCAD
Back to top button