Although you can enter AutoLISP code at the AutoCAD Command prompt or Visual LISP Console window prompt (AutoCAD for Windows only), any functions you define are lost when you close the drawing or session they were created in.
AutoLISP source code can be saved to an ASCII text file with a .lsp extension. Saving AutoLISP source code to a file has the following advantages:
- Programs are not lost when the drawing they are defined in is closed.
- Programs can be used in more than one drawing and can be executed on multiple machines.
- Programs can be shared with others in your organization.
- Testing and debugging multiple expressions is considerably easier.
AutoLISP source code can also be stored in files with a .mnl extension. A Menu AutoLISP (MNL) file contains custom functions and commands that are required for the elements defined in a customization (CUIx) file. A MNL file is loaded automatically when it has the same name as a customization (CUIx) file that is loaded into the AutoCAD-based product.
For example, in AutoCAD for Windows, when acad.cuix is loaded, the file named acad.mnl is also loaded if it is found in one of the folders listed as part of the program's Support File Search Path. If a CUIx file does not have a corresponding MNL file, no error is displayed, the product just moves and loading other support files.