This is a guest post by Sanjay Kulkarni, an AutoCAD programmer.
This post describes the method to load an AutoLISP program in an open drawing.
Some basic & fundamental information before we move to the procedure
An AutoLISP program runs inside (in the same workspace of) an open drawing. Therefore it is necessary to load the program in each individual drawing you want to use the program in. You can load a program into a drawing at any time.
Once you load the program in a drawing, it remains loaded into that specific drawing until the drawing is closed. This means that you can use the functions in the program multiple times once you load the program.
The flip side is that you can’t unload an AutoLISP program once you load it except by closing the drawing.
Did you find this tip helpful?
Don't miss new tips!
Plus get a free Dynamic Blocks tutorial
Enter your name and email below
If you want to use the same program in multiple drawings, you will need to load the program in each individual drawing even if there exists a drawing in which the program has been already loaded.
Loading an AutoLISP program
Now to the action:
- Type appload at the command prompt (In AutoCAD 2012, you can go to Manage tab>Applications panel>Load Application.). This will display the Load/Unload Applications dialog box as shown below.
- Click the History List tab at the bottom of the dialog box. In case the program was previously loaded in any drawing with Add to History checked, it will be listed there. Select the desired file in the list and go to step 7. Otherwise, go to step 3.
- Make sure that Files of type displays the .lsp extension.
- Using the LookIn drop-down, you browse to the desired location (folder).
- If you want to be able to use step 2 above in future, select the Add to History checkbox.
- Select the .lsp file to load in the window.
- Click Load. If the file is successfully loaded, a message to that effect is displayed at the bottom of the dialog box. Also if you have checked Add to History, the names of loaded programs are added to in the History List tab of the window.
- Click the Close button to close the dialog box.
You are now ready to use the functions in the loaded files.
- You can select multiple files in the History List or the browser using Shift & Control keys and then click the Load button to load all the selected files simultaneously.
- You can double-click on an individual file to both select and load it. Then you don’t need to click the Load button.
- When you double-click on a file in History List with Add to History checked, the file name is added again to the History List. You can remove filenames in the History List by selecting the file and clicking the Remove button.
- If you load a file multiple times in a drawing, AutoCAD does not generate any error and overwrites the previous version of the loaded file.
For a quicker method of loading a program, see the tip, “Loading AutoLISP programs quickly.” This will also obviate the need to load program in each drawing.
Sanjay Kulkarni is an experienced CAD (AutoCAD, Inventor, SolidEdge, CATIA, NX) programmer and a member of the Autodesk Developer Network. He is fluent in AutoLISP, VBA, and VB.NET. He has written for AugiWORLD and Inside AutoCAD (a monthly magazine that has since gone out of publication). You can contact him at [email protected]