Overview of AutoLISP Automatic Loading (Concept)

AutoCAD

 
Overview of AutoLISP Automatic Loading
Concept Quick Reference
 
 
 

AutoCAD loads the contents of three user-definable files automatically: acad.lsp, acaddoc.lsp, and the MNL file that accompanies your current customization file. By default, the acad.lsp file is loaded only once, when AutoCAD starts, whereas acaddoc.lsp is loaded with each individual document (or drawing). This lets you associate the loading of the acad.lsp file with application startup, and the acaddoc.lsp file with document (or drawing) startup. The default method for loading these startup files can be modified by changing the setting of the ACADLSPASDOC system variable.

If one of these files defines a function of the special type S::STARTUP, this routine runs immediately after the drawing is fully initialized. The S::STARTUP function is described in S::STARTUP Function: Postinitialization Execution. As an alternative, the APPLOAD command provides a Startup Suite option that loads the specified applications without the need to edit any files.

The acad.lsp and acaddoc.lsp startup files are not provided with AutoCAD. It is up to the user to create and maintain these files.

Command Autoloader

When you automatically load a command using the load or command functions, the command's definition takes up memory whether or not you actually use the command. The AutoLISP autoload function makes a command available without loading the entire routine into memory. Adding the following code to your acaddoc.lsp file automatically loads the commands CMD1, CMD2, and CMD3 from the cmds.lsp file and the NEWCMD command from the newcmd.lsp file.

(autoload "CMDS" '("CMD1" "CMD2" "CMD3")) 
(autoload "NEWCMD" '("NEWCMD")) 

The first time you enter an automatically loaded command at the command prompt, AutoLISP loads the entire command definition from the associated file. AutoLISP also provides the autoarxload function for ObjectARX applications. See autoload and autoarxload in the AutoLISP Reference in the Help system. To display Developer Help, click Help menu Additional Resources Developer Help.

NoteLike-named AutoLISP startup files are loaded based on their Modified time stamp; the LSP file with the most recent time stamp is loaded unless you specify the full file name (including the file name extension).