Learn the basics of AutoCAD and More!

Lesson 5.13 – Creating Loadable Routines

βš™οΈ Lesson 5.13 – Creating Loadable Routines with AutoLISP

Learn how to make your AutoLISP scripts load automatically using startup scripts and autoload techniques.


πŸ“š What You’ll Learn

By the end of this lesson, you’ll be able to:

  • Organize your AutoLISP code into separate, reusable files
  • Enable AutoCAD to load your code automatically at startup
  • Use autoload to delay loading until needed
  • Configure your environment with a startup script

🧠 Why It Matters

If you use AutoLISP tools regularly, you don’t want to reload them manually each time you open AutoCAD. By setting up autoloading and startup routines, you can save time, reduce friction, and maintain a clean, modular codebase.


πŸ› οΈ Tools You’ll Use

Tool / FunctionPurpose
loadLoads an AutoLISP file immediately
autoloadDelays loading until a specific function is called
acad.lspAutoCAD script that runs at session start
startup.lspCustom file that runs after AutoCAD finishes loading
APPLOADDialog box to manage startup loading

🧭 Lesson Structure

1️⃣ Create a Loadable LISP File

Save your function in a standalone .lsp file. For example:

πŸ“„ greeting.lsp

(defun c:greet ( / )
(alert "Welcome to your custom AutoCAD workspace!")
(princ)
)

2️⃣ Load Manually with load

You can test it manually:

(load "greeting.lsp")
(greet)

πŸ”Ž Ensure the .lsp file is in a support path (Options β†’ Files β†’ Support File Search Path)

3️⃣ Use autoload for On-Demand Loading

Add this to startup.lsp or acad.lsp:

(autoload '("greet") "greeting.lsp")

AutoCAD won’t load the file until greet is calledβ€”saving memory and boot time.

4️⃣ Add to startup.lsp for Session Load

The startup.lsp file runs after AutoCAD fully initializes. You can load multiple routines:

πŸ“„ startup.lsp

(princ "\\nCustom AutoLISP startup script running...")

(load "greeting.lsp")
(load "layer_setup.lsp")
(princ)

Place this file in AutoCAD’s Support File Search Path.

βœ… Lesson Checklist

TaskCompleted
Created reusable LISP files☐
Used load to test manually☐
Applied autoload for performance☐
Created and used startup.lsp☐
Added LISP files to Support File Search Path☐

πŸ“Œ Quick Tips

TipWhy It Helps
Keep routines modular (1 file = 1 tool)Easier maintenance and reuse
Use autoload for tools used occasionallyImproves AutoCAD launch performance
Use APPLOAD to test or manage loaded filesGraphical way to manage LISP files
Always add (princ) at end of startup scriptsSuppresses unwanted command line output

🧩 Real-World Applications

Use CaseWhat LoadsWhy It Helps
Office-wide toolsetBlock insertion, layer setupReduces need for manual loading
Developer toolkitLISP function libraryShare common tools across projects
Custom welcome routineGreeting, logging, tipsImproves user engagement

πŸ“ Files and Resources

File / ResourceDescription
greeting.lspSimple tool with alert message
startup.lspSample file to load multiple LISP routines at startup
autoload_example.lspTemplate showing how to defer load with autoload
load_order_checklist.docxPrintable checklist to help you organize routine loading

πŸ“– Review Table

FunctionDescriptionExample
loadLoads a LISP file(load "file.lsp")
autoloadDelays load until function is called(autoload '("func") "file.lsp")
princEnds routine quietly(princ)
APPLOADGUI for loading apps/scriptsType APPLOAD in the command line