Glossary · CAD and BIM
What is AutoLISP? Meaning, Example and How It Works
In simple words
AutoLISP is the programming language built into AutoCAD for adding your own commands and automating repeated drawing work. A short AutoLISP file can draw, count, measure or change objects in seconds instead of minutes. CAD drafters, CAD managers and engineers write or load AutoLISP routines to save time on repeated work.
It is based on the LISP language and was added to AutoCAD in the mid-1980s. Programs are plain-text .lsp files that can be compiled to .fas files or packaged as .vlx files. Full AutoCAD supports it, and AutoCAD LT for Windows added AutoLISP and dialog boxes (DCL) in its 2024 release.
Why it matters
Many drawing tasks repeat on every project, such as adding up lengths, counting items or renaming layers. A routine does the task the same way every time, which saves time and avoids typing errors. Since the 2024 release, AutoCAD LT for Windows also runs AutoLISP and DCL, so the same routines reach more users.
How it works
A function defined with defun whose name starts with c: becomes a command you can type, just like LINE or COPY. Inside it, AutoLISP can ask for points and objects (getpoint, ssget), read an object's data (entget), do the arithmetic and change or create objects. Code is written in any text editor; Autodesk's extension for Visual Studio Code adds editing and debugging, and the older Visual LISP editor is also available.
Worked example: total length of selected lines
This routine adds up the lengths of the lines you select and prints the total.
(defun c:ZYLEN (/ ss i e total)
(setq ss (ssget '((0 . "LINE"))) total 0.0 i 0)
(if ss
(repeat (sslength ss)
(setq e (entget (ssname ss i))
total (+ total (distance (cdr (assoc 10 e)) (cdr (assoc 11 e))))
i (1+ i))))
(princ (strcat "\nTotal length: " (rtos total 2 2)))
(princ))
How it reads: ssget lets you select objects but keeps only lines; for each line, entget reads its data, group 10 is the start point and group 11 the end point, and distance measures between them. rtos turns the total into text with 2 decimal places.
Run on three wall lines of 4.00 m, 3.50 m and 4.00 m, the command line shows "Total length: 11.50" because 4.00 + 3.50 + 4.00 = 11.50. In a drawing set in metres that is 11.50 m of wall line.
Step by step: using a routine
- Save the code as a plain-text file, for example zylen.lsp.
- In AutoCAD, run APPLOAD, select the file and click Load (add it to the Startup Suite to load it in every session).
- Type the command name, here ZYLEN, and press Enter.
- Answer the prompts, here by selecting lines, and read the result.
Types
- .lsp: plain-text source code, readable and editable.
- .fas: a compiled form of one program.
- .vlx: a packaged application that can hold several files.
AutoCAD and AutoCAD LT
Most AutoLISP code runs in both. In LT, functions that create 3D solids or surfaces, link to other applications or rely on ObjectARX and .NET add-ons do not work, and compiling to .fas or .vlx needs full AutoCAD for Windows, although LT can load compiled files.
Common mistakes
- Loading routines from unknown sources: a routine runs with your rights and can change drawings or settings. Keep the secure-load setting on and use trusted folders.
- No error handler, so a cancelled command leaves system variables (such as object snaps) changed.
- Command names that clash with another routine or a built-in alias.
- Forgetting the final (princ), so the last returned value is echoed on the command line.
- Assuming drawing units: the same routine gives 11500 in a drawing set in millimetres.
Related terms
- CAD and BIMGlossary term
Block (AutoCAD)
A block in AutoCAD is one or more objects combined into one named object, such as a door or a title block. The definition is stored once; every copy you place points to it, so editing the definition updates all copies.2 min read · Added 20 Nov 2026 - CAD and BIMGlossary term
Layer (AutoCAD)
A layer in AutoCAD is a named group for objects of the same kind, such as walls, doors or text. Each layer sets default colour, linetype and lineweight, and can be turned off, frozen or locked.2 min read · Added 20 Nov 2026 - CAD and BIMGlossary term
DWG file
DWG is the native drawing file format of AutoCAD. It stores 2D and 3D geometry, layers, blocks, text, dimensions, layouts and drawing information. It is owned by Autodesk and is one of the most widely used formats for sharing CAD drawings.1 min read · Added 20 Nov 2026 - CAD and BIMGlossary term
Model space and paper space
In AutoCAD, model space is where you draw the real object at full size (1:1). Paper space is the sheet layout, with a title block and viewports that show scaled views of the model for printing.2 min read · Added 20 Nov 2026
Frequently asked questions
How do I load a LISP file?
Use APPLOAD, or add it to the Startup Suite to load it every time.
Is AutoLISP safe?
A LISP runs with your AutoCAD rights. Use files only from sources you trust, and keep SECURELOAD on.
What are .fas and .vlx files?
Compiled forms of AutoLISP programs; .vlx can package several files together.