(redraw) redraws the current viewport and returns nil
(redraw en) redraws the entity whose name is in variable en
(redraw en 1) same as previous expression
(redraw en 2) blanks out the designated entity. The entity is not erased; it can be restored to screen using either of the two previous expressions.
(redraw en 3) highlights the designated entity
(redraw en 4) de-highlights the designated entity
(graphscr) flips to graphics screen (same as pressing F2 while text screen is displayed) and returns nil
(textscr) flips to text screen (same as pressing F2 while graphics
screen is displayed) and returns nil
(getvar "lunits") returns an integer (1 - 5) indicating the current
"system units" (scientific, decimal, engineering, architectural, or fractional)
which is stored in the system variable LUNITS
(getvar "snapunit") returns a point (stored in system variable SNAPUNIT) whose coordinates represent the current X and Y snap spacing
If the variable is named incorrectly, getvar returns nil.
(setvar "limmax" (list 14.0 9.25)) assigns the coordinates 14.0,9.25
to the system variable LIMMAX which holds the upper right corner of limits
(setvar "orthomode" 1) assigns 1 to system variable ORTHOMODE, which turns ortho on. Assign 0 to turn ortho off.
(setvar "cmdecho" 0) assigns 0 or system variable CMDECHO, which turns off the screen echo of commands and prompts when the command function is used. Assign 1 to turn it on.
(setvar "osmode" 1) installs endpoint as the running osnap mode
(setvar "osmode" 3) installs endpoint and midpoint as the running osnap modes (the 3 is interpreted as 1 + 2)
osmode takes as second argument: 0 = none, 1 = endpoint, 2 = midpoint,
4 = center, 8 = node, 16 = quadrant, 32 = intersection, 64 = insertion
point, 128 = perpendicular, 256 = tangent, 512 = nearest, 1024 = quick,
2048 = apparent intersection
(command ".circle" (list 2 2) 0.5) draws a 0.5 radius circle at
2,2. The period before the command name insures that the built-in
AutoCAD command will be used, just in case this command has been UNDEFINEd.
After (setq p1 (list 4 3) p2 (list 5 3))
(command ".line" p1 p2 "" ) draws a fine from 4,3 to 5,3 and exits the LINE command. The null string at the end of this expression has the effect of a carriage return ('Enter').
(command ".circle" pause 0.375) pauses for user to indicate the location of the center of the circle using the pointer or keyboard, then enters 0.375 for the radius of the circle.
As illustrated in the previous expression, the pre-assigned variable pause works well in a command function with many of the AutoCAD commands. However, if you want to use it with the TEXT command to pause for text to be entered, you must set system variable TEXTEVAL to non-zero. Also, do not use pause to draw with the SKETCH command.
Transparent commands (including realtime zoom and pan) can be used while AutoLISP is waiting for a response, such as during a getpoint. Transparent commands (but not realtime zoom and pan) can be used during a pause.
(command) effects an Esc (escape)
Several command sequences can be placed after the command function as
(command ".line" p1 p2 "" ".circle" p3 r1)
Calculation results can be submitted repeatedly to a command without having to leave the command by using the command function as illustrated below:
(setq p (list 2.0 2.0))
(repeat 5 (command p)
(setq p (polar p 0.6 1.5)))
(acad_colordlg 1) displays the color selection dialog box with
color 1 (red) as the default
(acad_colordlg 4) displays the color selection dialog box with color 4 (cyan) as the default
The first argument, which indicates the color to show in the dialog box as the default, can range from 0 through 256 (0 = BYBLOCK, 256 = BYLAYER).
(acad_colordlg 6 nil) displays the color selection dialog box with color 6 (magenta) as the default, and the BYBLOCK and BYLAYER buttons disabled.
The optional second argument, if set to nil, disables the buttons for
selecting BYBLOCK and BYLAYER. The BYBLOCK and BYLAYER buttons are
enabled if the second argument is omitted or set to non-nil.
(menucmd "s=assist") switches screen menu to the "assist" submenu
in the standard ACAD.MNU file
(menucmd "p3=*") pulls down the "POP3" section of the pull-down menu of the current menu file
(menucmd "p0=*") pulls down (pops up?) the cursor menu section of the current menu file
The first part of the string argument (before the equal sign) can be:
B1-B4 for button menus, A1-A4 for Aux menus, P0-P16 for pull-down menus,
I for image tile menus, S for screen menus, or T1-T4 for tablet menus.
After establishing two viewports, divided vertically
(vports) returns a list similar to:
((4 (0.5 0.0) (1.0 1.0))
(3 (0.0 0.0) (0.5 1.0)))
The pairs of coordinates are the lower left and upper right corners
expressed as fractions of the graphics screen. The current viewport is
always listed first.
After setting up a view in a particular viewport, then saving it with
the save option of the VIEW command under the name "iso," and after (setq
vlist (tblsearch "view" "iso"))
(setview vlist 4) establishes a view in viewport 4 that is the same as that saved in the view table under "iso"
If the second argument is 0, the view is established in the current
Because of AutoCAD's ability to work in 3D space and establish different User Coordinate Systems, a special problem exists for the AutoLISP programmer. Suppose variable p holds a list of 3 numbers which are the coordinates of a particular point in the WCS. The user now adopts a different UCS. That same variable (whose numbers have not changed) now represents a different location in space because those coordinates are now interpreted in a different coordinate system. If the programmer wants to use the original location of the point for some drawing or editing operation in the current UCS, he/she must translate that location into new coordinates using the trans function.
Locations stored in the drawing database are stored in coordinates from the entity's coordinate system, or ECS (which for many non-circular entities is the same as the WCS). Naturally, when the user changes to a new UCS, the points stored in AutoCAD's drawing database still represent the same location. When those coordinates are retrieved in order to be displayed (for example, by the LIST command) they are adjusted according to the current UCS. But coordinates stored in an AutoLISP variable do not change to match a new UCS when they are retrieved; rather, they must be translated with the trans function in order to represent their original locations.
The first argument is a list of three reals representing a 3D point.
The second and third arguments identifies the coordinate systems the
point is being translated from and to, respectively. These arguments
can be any of the following:
0 = WCS
1 = Current UCS
2 = Display coordinate system for the current viewport when used with 0 or 1
an entity name (such as one retrieved by the entlast function) = the coordinate system of that entity
After establishing a current UCS whose origin is shifted to 4,3 in the
old coordinate system (WCS),
(trans (list 0 0 0) 0 1) returns (-4.0 -3.0 0.0)
(trans (list 5 1 2) 0 1) returns (1.0 -2.0 2.0)
(trans (list 5 1 2) 1 0) returns (9.0 4.0 2.0)
After establishing a current UCS which is rotated 90° around the
X axis of the old coordinate system (WCS),
(trans (list 5 1 2) 0 1) returns (5.0 2.0 -1.0)
(trans (list 5 1 2) 1 0) returns (5.0 -2.0 1.0)
After VPOINT 1,-2,1 then UCS View,
(trans (list 5 1 2) 0 2) returns (4.91935 1.27802 2.04124)
(trans (list 5 1 2) 2 0) returns (5.10606 0.968223 1.72937)
More complete explanation found in AutoCAD R14 Customization Guide
under the trans function and under "Coordinate System Transformations."