Creating commands that use AutoLISP is a more advanced way to use the program's customization feature.
You can use AutoLISP variables and expressions to create macros that perform complex tasks. When the program loads a CUI/CUIx file, it also loads a MNL file with the same name and in the same location. Placing AutoLISP code in a MNL file is an efficient way to load custom commands that can be used in a macro.
This example is composed of three command macros that are used to insert a block.
Command macro prompts for the window width.
^C^C^P(setq WINWID (getreal "\nEnter window width: ")) ^P
Command macro prompts for the wall thickness.
^C^C^P(setq WALLTHK (getreal "\nEnter wall thickness: ")) ^P
Command macro inserts a block named "window" and prompts for the insertion point and rotation.
^C^C_INSERT window XScale !WINWID YScale !WALLTHK
The X axis of the block is to the current window width and its Y axis to the current wall thickness.
This example contains two command macros that increase or decrease the current value of the GRIPSIZE system variable.
Command macro increases the value of the GRIPSIZE system variable by 1.
^P(setvar "gripsize"(1+ (getvar "gripsize")))(redraw)(princ)
Command macro decreases the value of the GRIPSIZE system variable by 1.
^P(setvar "gripsize"(1- (getvar "gripsize")))(redraw)(princ)
To add validity checking to these command macros, values less than 0 and greater than 255 cannot be used for the GRIPSIZE system variable.
The following example prompts for two points and draws a rectangular polyline with the specified points as its corners.
^P(setq a (getpoint "Enter first corner: "));\+ (setq b (getpoint "Enter opposite corner: "));\+ pline !a (list (car a)(cadr b)) !b (list (car b)(cadr a)) c;^P
Using the following syntax, you can programmatically execute a pull-down menu item's macro:
(menucmd "Gcustomizationgroup.element_ID=|")
The previous syntax works only if the menu item is part of a menu that is on the program's menu bar and is available for use.