Autolisp code – what do you do with it?

So you found some autolisp code online that you want to try out. what do you do with it? How do you get it into AutoCAD and make it do what it says it will do? Let’s use this sample lisp code, from Paul Turvill’s site,

  • You could copy the code and paste it in at the command line, one line at a time or the whole bunch all at once. We don’t recommend this method, because many times this will fail due to extra returns in the text. Anyway, the functions in that code will only be available in the currently loaded drawing. You’re probably going to want to use this code more than once.
  • If you are on a Windows machine, open Notepad and paste the code in. Save it as a .lsp file by either enclosing the entire file name in quotes when you go to save it (i.e. “mylispfile.lsp”) or change the “SaveAs” type to All Files. You can read more about this here, including instructions for Mac O/S. Watch out for this little “gotcha” when copying and pasting autolisp code. You probably will not catch this if you use Notepad.

lisp code in Notepad

  • Also only available on Windows, there is a Visual Lisp Editor built into AutoCAD (2000 and later). At the AutoCAD command line, type in VLIDE and press enter. Create a new document and paste in the code, or start writing from scratch if you are so inclined. This application is made for authoring and editing autolisp (and other customization) files. When you go to save from this application, Lisp Source Files is the default choice and you don’t have to do anything special to end up with a .LSP file. You can read more about this here. As you become more advanced working with autolisp files, you can explore features such as breakpoints, stepping through the code one line at a time, compiling your autolisp code, and working with projects.


So, now you have a .LSP file (or maybe you downloaded an intact .LSP file. How do you load it and get it to work in AutoCAD? My favorite method and a very easy way, is to simply drag and drop the .LSP file from Windows Explorer, into the AutoCAD editor screen. Our friend Lee Mac has outlined all of the other ways to load (and potentially auto-load each time a drawing is opened) autolisp files…., just click here.