Sunday, December 28, 2014

AutoLISP Tutorial for AutoCAD Users: Lesson 3

It's not all that comforting to know how to define a custom command if you can't save it and use it tomorrow or next year. Let's save our work.

See also the prettier version of this lesson.

File it

The way to save your AutoLISP work is to keep it in an AutoLISP Application Source (lsp) or sometimes an AutoLISP Menu Source (mnl) file.

If you are a programmer or an experienced computer user, you already have your own system (I recommend Notepad++) for text file editing and management. If not, this is a great time to learn. We will file the AutoLISP program on your Windows Desktop.
  1. Type this at the AutoCAD command line: notepad
  2. Press [Enter] again instead of supplying a file name.
  3. The Windows Notepad file editor will open.
  4. Select the File, Save As... menu
  5. The Save As form will open:
  6. Browse to the Windows Desktop:
  7. Type l0.lsp in the "File name:" area: 
    (defun c:l0 () (command "._layer" "_thaw" "0" "_set" "0" "_unlock" "0" "_on" "0" ""))
  8. Click the Save button.
  9. Type the (c:l0) function into the Notepad window:
  10. Save and Exit Notepad.
That was easy if you've done it before. Sorry it was so hard if you haven't. There is no easier way.

Load it

To use your AutoLISP program, you have to load it into AutoCAD. Show the Desktop or browse to the Desktop in Windows Explorer. Then drag l0.lsp to the AutoCAD drawing area. If the AutoCAD drawing area isn't visible, drag l0.lsp onto the AutoCAD program on the Windows Taskbar, hold a second or two, then drag it into the AutoCAD drawing area when AutoCAD appears.

Now let's learn how to make it a part of your system permanently.

Previous lessons

No comments: