Use AutoLISP Applications (Concept)

AutoCAD

 
Use AutoLISP Applications
Concept Quick Reference
 
 
 

AutoLISP applications are stored in ASCII text files that you can edit. Before you can use an AutoLISP application, it must first be loaded.

AutoLISP applications are stored in ASCII text files with the .lsp extension. These files generally have a header portion that describes a routine, its use, and any specific instructions. This header might also include comments that document the author and the legal information regarding the use of the routine. Comments are preceded by a semicolon (;). You can view and edit these files with a text editor or word processor that can produce an ASCII text file.

Before you can use an AutoLISP application, it must first be loaded. You can use the APPLOAD command or the AutoLISP load function to load an application. Loading an AutoLISP application loads the AutoLISP code from the LSP file into your system's memory.

Loading an application with the load function involves entering AutoLISP code at the command prompt. If the load function is successful, it displays the value of the last expression in the file at the command prompt. This is usually the name of the last function defined in the file or instructions on using the newly loaded function. If load fails, it returns an AutoLISP error message. A load failure can be caused by incorrect coding in the file or by entering the wrong file name at the command prompt. The syntax for the load function is

(load filename [onfailure]) 

This syntax shows that the load function has two arguments: filename, which is required, and onfailure, which is optional. When loading an AutoLISP file at the command prompt, you typically supply only the filename argument. The following example loads the AutoLISP file newfile.lsp.

Command: (load "newfile")

The .lsp extension is not required. This format works for any LSP file in the current library path.

To load an AutoLISP file that is not in the library path, you must provide the full path and file name as the filename argument.

Command: (load "d:/files/morelisp/newfile")

NoteWhen specifying a directory path, you must use a slash (/) or two backslashes (\\) as the separator, because a single backslash has a special meaning in AutoLISP.