Creating commands that use AutoLISP is a more advanced way to use the AutoCAD customization feature.
You can use AutoLISP variables and expressions to create macros that perform complex tasks. To use AutoLISP efficiently in macros, place AutoLISP code in a separate MNL file. AutoCAD loads the MNL file when it loads a CUI file with the same name and in the same location.
You can specify additional AutoLISP files to load in the Customize User Interface (CUI) Editor. Creating commands that use AutoLISP is a more advanced way to use the AutoCAD customization feature. Carefully study the following examples and the information in the AutoLISP Reference and the AutoLISP Developer's Guide. To access the additional help resources, click Help menu Additional Resources Developer Help.At the command prompt, enter help. Experimentation and practice will help you use this feature effectively.
To programmatically execute a pull-down menu macro, use the following syntax:
(menucmd "Gmenugroup.element_ID=|")
The previous syntax works only if the menu macro is part of a menu that is on the AutoCAD menu bar and is available for use. For more information about this syntax, see the AutoLISP Reference.
An application that uses block insertion presets could provide commands like these: [Set WINWID][Set WALLTHK][Insert Window]
^C^C^P(setq WINWID (getreal "Enter window width: ")) ^P
^C^C^P(setq WALLTHK (getreal "Enter wall thickness: ")) ^P
^C^C_INSERT window XScale !WINWID YScale !WALLTHK
This code inserts the block named “window,” scaling its X axis to the current window width and its Y axis to the current wall thickness. In this example, the actual values come from the user-defined AutoLISP symbols WINWID and WALLTHK. The rotation is up to the user to decide so that the window can be rotated in the wall.
With the following commands, grip size adjustment can be done on the fly:
^P(setvar "gripsize"(1+ (getvar "gripsize")))(redraw)(princ)
^P(setvar "gripsize"(1- (getvar "gripsize")))(redraw)(princ)
To add validity checking to these commands, values less than 0 and greater than 255 cannot be used for the GRIPSIZE system variable.