AutoCAD LISP Basics: A Trainer Shows Your First Routine in an Hour

AutoLISP basics let you write a short text file, load it into AutoCAD, and run it as a working command within an hour. The three primitives to learn first are defun to define a function, setq to store values, and load to bring your code into a drawing session. Once those click, you can automate repetitive drafting tasks instead of clicking through them by hand. The next sections walk through runnable examples so you can confirm it works on your own machine.
TL;DR:
Standard AutoCAD LT does not run AutoLISP directly; only certain versions and configurations may support precompiled routines, so verify compatibility before building a workflow.
AutoCAD blocks code from untrusted folders, often without a clear error; add the script folder to TRUSTEDPATHS, then restart after changing security or search settings.
ACAD.LSP loads once per session, while ACADDOC.LSP loads for each drawing; AutoCAD uses the first matching file in its support path, so place yours highest.
Test unfamiliar routines in a scratch drawing after backing up project files, and inspect file commands such as WBLOCK or SAVEAS for possible overwrites.
Because AutoLISP uses dynamic scope, declare working variables after a slash in the function definition to prevent values from lingering and colliding with other routines.
Table of Contents
Quick start: write, save, load, and run a simple AutoLISP routine
Loading and auto-loading: search path, acad.lsp, acaddoc.lsp, and secure-loading basics
Three short, runnable examples beginners should study and adapt
Where to find authoritative docs and community code, and how to reuse it safely
Trainer perspective: why AutoLISP is worth learning for drafters and architects
AutoLISP 101: what AutoLISP is and when to use it
AutoLISP is a dialect of the Lisp programming language built specifically for AutoCAD, letting you script drawing creation, modify entities, and automate repetitive commands instead of running them manually. It has shipped with AutoCAD since the 1980s, making it one of the oldest customization languages still in active use for CAD work.
AutoLISP runs in AutoCAD’s full desktop products. AutoCAD LT does not run AutoLISP directly, though some LT workflows can still use pre-compiled routines depending on the version and configuration, so check your product’s documentation before assuming a script will load.
Lisp dialects share a few traits that feel unusual at first but become second nature quickly:
Code and data both live inside parentheses as lists, so a function call and a piece of data look structurally similar.
Variables use dynamic scope by default, meaning a value set in one function can leak into another unless you manage it deliberately.
You can type expressions directly into the command line and see results immediately, which makes experimentation fast.
Typical beginner use cases include labeling points, batch-renaming layers, inserting repetitive blocks, and pulling coordinate data out of a drawing for a schedule. None of these require advanced programming, just a grasp of a handful of functions.
Quick start: write, save, load, and run a simple AutoLISP routine

A .LSP file is nothing more than plain text, so any text editor works, though a dedicated AutoLISP editor catches mismatched parentheses faster. Save this as hello.lsp:
(defun C:HELLO ()
(princ "
Hello from AutoLISP.")
(princ)
)
Here’s the full sequence to get it running:
Save the code above in a plain text file named hello.lsp, with no .txt extension hiding behind it.
Open AutoCAD, type APPLOAD, browse to the file, select it, and click Load, or type (load "C:/path/hello.lsp") directly at the command line.
Type HELLO at the command line and press Enter to run it.
If AutoCAD reports a security block instead of running the code, add the folder to your trusted locations before trying again.
When you call load, AutoCAD searches its library path and tries file extensions in a specific order: .vlx, then .fas, then .lsp. VLX files are compiled and only supported on Windows, which matters if you are sharing routines across platforms. For a plain .LSP file like the one above, none of that matters yet, but it explains why a compiled version of the same routine might behave differently later.
Core syntax and the functions to learn first
Five functions cover most of what a beginner routine needs, and learning them in combination gets you further than memorizing the full function reference. Instructor guidance for new AutoLISP users consistently points to mastering setq and defun before anything else, since nearly every other function builds on storing and retrieving values.
defun defines a function; prefixing the name with C: turns it into a command you can type directly, as shown with C:HELLO above.
setq assigns a value to a variable, for example (setq pt1 (getpoint " Pick a point: ")).
princ prints a value to the command line without the extra formatting that print adds, and calling (princ) alone at the end of a function suppresses the trailing nil echo.
command runs a native AutoCAD command from inside your routine, for example (command "LINE" pt1 pt2 "").
getpoint prompts the user to pick a location in the drawing and returns it as a list of coordinates.
Pro Tip: Declare working variables as local by listing them in the function’s argument list after a slash, like (defun C:MYCMD (/ pt1 pt2) ...), so they do not linger and collide with other routines.
Loading and auto-loading: search path, acad.lsp, acaddoc.lsp, and secure-loading basics
Manually loading a file every session gets old fast, so AutoCAD supports auto-loading through two special files: ACAD.LSP, which loads once per session, and ACADDOC.LSP, which loads for every drawing you open. Both must sit in AutoCAD’s primary support file search path to be found.
That search path matters because AutoCAD loads the first matching file it finds and stops looking. If a folder containing your custom acad.lsp sits lower in the Support File Search Path than another folder with a file of the same name, your version never runs.
A short checklist keeps this from becoming a mystery:
Open Options > Files and move your custom support folder to the top of the Support File Search Path list.
Confirm SECURELOAD is set appropriately and that your folder is listed under TRUSTEDPATHS, since AutoCAD blocks execution from untrusted locations by default.
Restart AutoCAD after changing the search path or trusted locations, since both are read at startup.
Debugging and security pitfalls beginners encounter
Most “my code won’t run” problems trace back to one of two causes: AutoCAD’s security settings, or a plain syntax mistake. Telling them apart saves time.
Pro Tip: If AutoCAD gives no error message at all and simply refuses to load a file, suspect security before suspecting your code.
A file sitting outside your trusted locations will often fail silently or show a loading prompt instead of an error, since secure mode restricts execution to folders listed in TRUSTEDPATHS.
A genuine syntax error, like a missing closing parenthesis, usually produces a clear error message naming the problem function.
Inserting extra princ statements between lines is the fastest way to confirm whether a variable holds the value you expect at each step.
Adding a folder to trusted locations removes the load prompt that otherwise blocks custom tools from running, which is often the single fix that resolves a routine that “does nothing” when loaded, according to guidance on configuring trusted locations. One more detail worth knowing: changing the LISPSYS variable, which controls ASCII versus Unicode support, requires an AutoCAD restart before it takes effect.
Editors and tools: Visual LISP IDE and VS Code workflows
You can write AutoLISP in Notepad, but a dedicated editor catches mistakes before you ever try to load the file. The Visual LISP IDE, bundled with AutoCAD on Windows, highlights matching parentheses and lets you step through code line by line, which makes it a natural fit for anyone just starting out.
VS Code with an AutoLISP extension suits readers who already use it for other work or who are on a platform without the Visual LISP IDE. It offers syntax highlighting and formatting without the full debugging console.
Use the Visual LISP IDE when you want to set breakpoints and inspect variable values interactively.
Use VS Code when you want a lightweight editor for quick edits and already have it installed.
Either way, keep the edit, load, test loop tight: save the file, reload it with APPLOAD, run the command, and repeat.
Three short, runnable examples beginners should study and adapt
Each of these builds on the last, so work through them in order rather than jumping to the most complex one first.
The hello world pattern from earlier is worth revisiting: notice the lone (princ) at the end, which exists purely to suppress the nil AutoCAD would otherwise echo after the function finishes. Leave it out and your clean output gets an ugly nil tacked on.
A setq example that stores a scale factor and returns it:
(defun C:SCALEFACTOR ()
(setq sf (/ 1.0 100.0))
(princ (strcat "
Scale factor: " (rtos sf 2 4)))
(princ)
)
A point-labeling command using the C: prefix to expose it as a typed command:
(defun C:LABELPT (/ pt)
(setq pt (getpoint "
Pick a point to label: "))
(command "TEXT" pt 0.2 0 "Point")
(princ)
)
Example | Core function introduced | What it demonstrates |
Hello world | princ | Clean command-line output without a trailing nil |
Scale factor | setq | Storing and reusing a calculated value |
Point label | getpoint + command | Prompting for input and triggering a native command |
Type LABELPT, click a point, and AutoCAD inserts a text label there, a small win that shows how quickly getpoint and command combine into something useful.
Where to find authoritative docs and community code, and how to reuse it safely
Autodesk’s own AutoLISP reference pages are the most reliable source for function syntax and behavior, including the exact load function documentation referenced earlier. The Wikipedia overview of AutoLISP is a useful starting point for understanding the language’s history and its relationship to Visual LISP.
Before running any routine copied from a forum or blog, a few habits protect your drawings:
Scan the code for command calls involving file operations like WBLOCK or SAVEAS, which can overwrite files without warning.
Back up your drawing before testing unfamiliar code, since a bug in someone else’s routine can modify entities you did not intend to touch.
Start with a scratch drawing rather than live project files when testing anything new.
Once the basics feel comfortable, try small projects: a layer cleanup routine, a block-counting tool, or a script that labels multiple points in sequence. For broader AutoCAD grounding alongside your scripting, our guide to getting started with AutoCAD covers the core commands worth knowing first.
Trainer perspective: why AutoLISP is worth learning for drafters and architects
A five-line routine that labels points or renames layers in bulk can save real time across a busy week of drafting. That compounding effect is what makes AutoLISP worth the initial friction. We have watched small, almost trivial scripts turn into the tools a drafter reaches for daily. Do not wait until you understand the whole language. Write something tiny, run it, break it, fix it, and repeat.
— Steve
S15Studio AutoCAD training: a practical next step
Learning the syntax is one thing. Applying it inside real project workflows is where it actually sticks, and that is the gap our AutoCAD Training course is built to close. We offer project-based lessons with trainer support and access to the material, so you can return to a lesson whenever a new drafting problem comes up.

Architecture students and junior drafters tend to get the most out of it, since the course moves from foundational AutoCAD skills toward the kind of automation habits covered in this guide. If you want a structured path instead of piecing it together from scattered tutorials, our AutoCAD Training page has the full course outline and enrollment details.
FAQ
What is LISP programming used for?
In AutoCAD, AutoLISP is used to automate repetitive drafting tasks, create custom commands, and manipulate drawing entities programmatically. Beyond CAD, Lisp dialects in general are used for symbolic computation and rapid prototyping, but AutoLISP specifically exists to customize AutoCAD’s behavior.
How do I work in AutoCAD basics before learning LISP?
Getting comfortable with core drawing and editing commands first makes AutoLISP easier to learn, since many routines simply automate commands you already know how to run manually. Our AutoCAD commands overview is a good starting point for building that foundation.
How do I set the language in AutoCAD for LISP support?
The LISPSYS system variable controls whether AutoCAD handles AutoLISP in ASCII or Unicode mode, which can matter for routines using non-English characters. Changing this setting requires restarting AutoCAD before it takes effect, so plan the switch outside of active work.
What are the first commands to automate with AutoLISP?
Simple, repetitive tasks make the best starting points: labeling points, renaming layers, or inserting a block at multiple locations. A short list of common manual commands worth automating first appears in our guide to AutoCAD commands, and each can become a one-function AutoLISP routine.
Can AutoLISP run in AutoCAD LT?
Standard AutoCAD LT does not run AutoLISP routines directly, since AutoLISP support is built into the full AutoCAD product line rather than LT. Check your specific AutoCAD LT version’s documentation if you need to confirm current behavior before relying on a script.
Sources
Recommended

Comments