• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
blog.draftsperson.net

blog.draftsperson.net

the art of technical drawing

blog.draftsperson.net

AI-Generated AutoLISP: What Actually Breaks (2026)

July 26, 2026

Nobody has written the failure list

Search any of the obvious queries — “can AI write AutoLISP”, “ChatGPT AutoLISP”, “AI generated AutoLISP code” — and you get two kinds of page. One is a tutorial on how to prompt it. The other is a forum thread where somebody pastes a broken routine and three veterans take turns fixing it. A ranking check across six of those queries on 27 July 2026 turned up GPT-directory listings, Udemy and Skillshare course ads, YouTube, forum threads and two vendor blogs. Not one page sorted the failures into a list.

The best of the editorial competition, IMAGINiT’s piece by Nick Turner from October 2025, gives you five steps: Define Your Task Clearly, Generate Code Using ChatGPT, Test in AutoCAD, Troubleshoot, Iterate for Improvement. That is the prompt-and-paste-the-error-back loop, written down honestly. It works for the errors AutoCAD tells you about. It has nothing to say about the ones it does not.

That list is what follows. It is drawn from two places only: the public record on the Autodesk forums and CADTutor between December 2022 and July 2026, and Autodesk’s own AutoLISP documentation. Nothing here was run in AutoCAD. This is a code review against the reference, not a test, and where a claim would need a live session to stand up it is not made.

The order is by blast radius — how far the damage travels, and how quietly.

Failure mode When you find out How far it travels
Invented function names Only when that branch runs Aborts mid-job, usually after the drawing has already been changed
Unrestored system variables Later. Much later. Into the DWG, or into the registry
No *error* handler First time anyone hits Esc Guarantees the row above
No undo group When the user types U N undos instead of one
ActiveX and platform assumptions On Mac, on web, or on a clean session Half the office cannot run it
Structural syntax errors At load Nowhere. It never runs.

1. Invented function names

This sits at the top because it is the failure that detonates all the others. It fires part-way through, after the routine has changed the current layer and zeroed the object snaps, and before it gets anywhere near the lines that put them back.

Kent1Cooper, on the Visual LISP board on 25 October 2024, is the anchor:

There have been numerous Topics raised here based on problems with AI-generated AutoLisp code [more commonly from ChatGPT] that was really way off — using assumed but non-existent function names, supplying incorrect arguments, etc. I guess we should assume that AI will get better at it over time, but so far….

On the same thread, DGCSCAD had a go at a find-and-replace routine and reported: “I had it add MLeaders, but that was full of made-up function definitions. I’ll be trying a different approach.”

The obvious fix occurred to Kent1Cooper too. In December 2025 he asked, in his own square brackets: “[Is it possible to embed the entire AutoLisp Reference in there as a “knowledge source,” so it won’t make up functions, use incorrect arguments, etc.?]” CodeDing answered nine minutes later — he had already tried it, and the answer is section 2 below.

Twenty months after Kent1Cooper’s post, on CADTutor in June 2026, a poster going by Least described the same thing in the present tense: “Copilot can be infuriating at times — it keeps using LISP functions that aren’t supported in AutoLISP, or ACAD-only functions that don’t work in BCAD.”

So this is not a 2023 problem that got quietly solved.

Why it is worse in AutoLISP than in most languages

In a language with a build step, a name that does not exist is caught before anything runs. AutoLISP has no such step. There is no import to resolve, no compiler to satisfy, and — in AutoCAD LT for Windows — not even the Visual LISP IDE, which Autodesk confirms “is not available in AutoCAD LT for Windows or on Mac OS”. The name is resolved when the call is evaluated. Until that line executes, a fabricated function is just text in a file that loads cleanly.

Put that together with the shape of the code these tools write. A routine with three branches — one for blocks, one for polylines, one for everything else — can be exercised on blocks all week and look fine. The invented call is sitting in the polyline branch.

The Common Lisp bleed

There is a specific flavour of this worth naming, because it is the one that survives a knowledge base. CodeDing, 15 December 2025:

I’ve tried. It makes it better, but still often confuses functions from Common Lisp as useable for AutoLisp. But I have noticed that as these newer AI models come out they do get much better at writing AutoLISP.

AutoLISP looks like Lisp and the training data is overwhelmingly not AutoLISP. Henry C. Francis put his finger on it back in May 2023: the model “doesn’t yet have a full knowledge of the limitations/differences in Autolisp vs LISP and VLX vs ActiveX.” He also noted the recovery path that everyone ends up on — “It will suggest alternate code if told of the invalid functions it had used and asked to rewrite it.” Which works, and which is also the whole business model of the tutorials on this SERP.

We keep a paste-in AutoLISP function allowlist for exactly this — it is cheaper to constrain the vocabulary up front than to catch a bad name on the day it fires.

2. Unrestored system variables

This is the one that leaves the building. Autodesk’s system variable reference gives every variable a “Saved in” field, and that field is the blast radius, spelled out by the vendor:

Variable Saved in What an unrestored change actually costs
CLAYER, ORTHOMODE Drawing Written into the DWG on save. Goes to whoever opens the file next.
OSMODE Registry Survives closing and reopening AutoCAD.
CMDECHO Not-saved Dies with the session, but the command line stays wrong until restart.

CLAYER “Sets the current layer” and is saved in the drawing. A routine that switches to a text layer, dies, and never switches back has written that into the file. Nobody reviews the current layer on a shop drawing check. It goes out.

OSMODE is saved in the registry, and this is where two sources lock together neatly. Lee Mac opens his error-handling page with the symptom:

Ever used a program only to discover some time later that your Object Snaps have been mysteriously cleared? Or maybe AutoCAD is suddenly behaving differently? These are tell-tale signs that you have aborted a program that is not equipped with an appropriate error handler.

Autodesk supplies the mechanism for why it is still cleared next Monday: OSMODE is “Saved in: Registry”. Nothing about restarting AutoCAD puts it back.

The idiom almost nobody uses

Near-universal practice — human and machine — is (setvar "osmode" 0). Autodesk documents something better, in a note on the OSMODE page:

Note: Developers creating custom routines can use the 16384 bitcode to temporarily suppress the current running object snap settings without losing the original settings.

Set the suppress bit instead of zeroing the variable, and a routine that dies before it restores has not destroyed the user’s snap selection. The note has been sitting in the reference for years. It is not the idiom you will find in most published LISP, generated or otherwise — this is one where the machines have simply learned what we do.

The mirror-image mistake is cargo cult. BLIPMODE has no page at all in the AutoCAD 2024 core system variables reference — the GUID returns a hard 404 — and Autodesk’s CAD Management Guide lists it under obsolete system variables with the instruction to “rewrite your custom programs to avoid the use of any obsolete commands or system variables”. A routine that dutifully saves and restores BLIPMODE is not being careful. It has absorbed a 1990s template.

3. No error handler, and Esc counts as an error

Section 2 describes what breaks. This is why it breaks so often. Lee Mac, again:

what most users don’t realise is that thumping the Esc key during program execution is also considered an error and will hence abort the program instantaneously

Where a generated routine does bother to restore a system variable, the restore is usually the last line before the closing bracket. On Esc, that line is unreachable. The routine stops where it stands, with the layer changed and the snaps off, and there is no handler to catch it. Autodesk’s instruction is plain: “Before defining your own *error* function, save the current contents of *error* so that the previous error handler can be restored upon exit.”

Lee Mac’s localised pattern is the thing to hold a generated routine against:

(defun c:test ( / *error* osm )

    (defun *error* ( msg )
        (if osm (setvar 'osmode osm))
        (if (not (member msg '("Function cancelled" "quit / exit abort")))
            (princ (strcat "\nError: " msg))
        )
        (princ)
    )

    (setq osm (getvar 'osmode))
    (setvar 'osmode 0)

    (rtos (getreal "\nPress Esc to exit, press Enter to force an error ..."))

    (setvar 'osmode osm)
    (princ)
)

Four things there, all load-bearing, and all of them things to check for by eye. *error* is declared in the local list, so the previous handler comes back on its own. The restore is guarded — (if osm ...) — because the error can fire before osm was ever set, and Autodesk documents that a bad type handed to setvar generates a further AutoLISP error, inside the error handler. The restore appears twice: in the handler and on the normal exit path. And it ends with a bare (princ), which Autodesk calls “exiting quietly”.

One spelling trap, since it is silent: Autodesk’s cancel string is “Function cancelled”, with the British double L. A handler testing for the American single-L spelling will not match and will print a spurious error on a plain Esc.

4. No undo group

Autodesk explains this failure better than we can, on the page about undoing changes made by a routine:

Each command executed with the command and command-s functions explicitly creates its own UNDO group. If a user enters U (or UNDO) at the AutoCAD Command prompt after running an AutoLISP routine, only the last command will be undone. Additional uses of UNDO will step backward further through the commands used in that routine. Users of your routine will expect that all of the operations that it performs can be undone in a single operation, instead of having to undo multiple operations to get back to the previous state of the drawing.

The fix is two lines, wrapping the work: (command "._UNDO" "_Begin") and (command "._UNDO" "_End"). Note Autodesk’s token order — dot first, then underscore. A lot of forum code writes _.UNDO; both prefixes are independent and both orderings work, but only one of them is a quote from Autodesk.

This one is not dangerous so much as it is the tell. A routine that draws six objects and cannot be taken back in one U was never finished.

5. ActiveX and platform assumptions

Get this section right, because a lot of the internet has it wrong.

The claim “AutoCAD LT has no ActiveX” is false. Autodesk’s own “What’s New or Changed with AutoLISP” page for AutoCAD LT 2024 says: “Most VL*, VLA*, VLAX*, and VLR* functions are supported, but the use of third-party automation libraries is not supported in to AutoCAD LT.” (The “in to” is Autodesk’s typo, quoted as found.) What LT actually excludes is a short, named list — vlax-create-object, vlax-get-object, vlax-get-or-create-object, vlax-import-type-library, vla-GetInterfaceObject, plus VLA* functions for 3D solids, surfaces, helixes, materials and multilines. If you have been telling your LT users that vla- is off the table since 2024, that is out of date.

The real portability line is the operating system. Autodesk’s vl-load-com reference page states its supported platforms as “Windows only; not available on Mac OS or Web”. Any generated routine reaching for vla- or vlax- is a Windows routine. command-s, by contrast, is documented as “Windows, Mac OS, and Web”. That is the sourced reason to prefer the command form of the undo group over vla-StartUndoMark, and it beats arguing about it.

Autodesk also documents the branch: check the PROGRAM system variable, which returns acadlt for LT, using the guard (if (/= (strcase (getvar "PROGRAM") T) "acadlt").

Then there is the missing first line. Autodesk:

AutoLISP code that includes calls to vla-, vlax-, or vlr- functions should always begin with a call to vl-load-com to ensure that the code will run; it should not be left up to the user to load the extensions. If your application does not call vl-load-com, the application may fail.

Note “may fail”, not “will fail”. If something earlier in the session already loaded the extensions, the offending routine works by luck. That is exactly why the omission survives a quick check on the machine it was written on and shows up on a colleague’s fresh session instead. Autodesk’s “it should not be left up to the user to load the extensions” is the direct answer to “but it worked when I tried it”.

6. Structural syntax errors

Last, because it is the loudest and therefore the least dangerous. It does not load, so it cannot hurt the drawing.

martti.halminen diagnosed it in December 2022 and the diagnosis has aged well:

Seems the fundamental problem here is that the system doesn’t know the syntax and semantics of IF, so it doesn’t know when to close the parentheses, and when to use PROGN to group commands for the correct semantics.

On the same thread, Kent1Cooper itemised four defects in one generated routine — worth reading in full as a model of what a review pass looks like. Two of his points, verbatim:

The (if) function at line 22 has its ‘then’ argument on the next line, but lines 25 through 35 need to be “wrapped” in a (progn) function to make it all into a single ‘else’ argument for the (if) in line 22.

The (foreach) function [line 31] is for stepping through a list, not a selection set such as (ssget) returns.

He also caught entsel being used where a multiple selection was wanted, and a MOVE call whose displacement coordinates were not wrapped in a (list). Notice the shape of that: two are pure syntax, two are “this function does not do what you think it does”. The second kind is the same failure as section 1, wearing a real function name.

The quiet one in the same family

Locals. Autodesk states the default plainly: “All variables when they are initially declared are global.” And the cost:

However, if all or many of your variables are global it becomes increasingly possible that you could end up changing the value of a variable so it is incompatible with another function. This can lead to unpredictable behavior and it can be very difficult to identify the source of a problem.

The slash-declared list — (defun c:FOO ( / pt1 pt2 ss ) — is the fix, and the spacing is a requirement rather than a style preference: “Be certain there is at least one space between the slash and each local variable.”

There is a good reason this is the item generated code misses most consistently, and Autodesk supplies it as a tip: “Do not make your variables local until after you have done most of the debugging for your function.” Declaring locals is a finishing step. It comes at the end of a debugging phase — and a routine that arrived in one shot never had one.

The honest verdict

The record does not say AI cannot write AutoLISP. Reading the same threads that produced every complaint above:

  • CodeDing, December 2025: “as these newer AI models come out they do get much better at writing AutoLISP.”
  • Least, June 2026, on Claude: “the code tends to run first time.”
  • Danielm103, June 2026: “The issue is, people expect LLMs to “one shot” solutions, it’s unlikely to happen.” And then: “If you spend time and find a system to work with the models, they are amazing.”
  • BIGAL, who started that thread: “Even I try AI now and again when stuck, it is successful some times.”

There is a dissent worth printing too. On the Autodesk forum in March 2024, _gile wrote: “Please don’t offend the natural intelligence of the people who provide help here by posting AI-generated code (the Stack Overflow site has banned generative AI).” That was aimed at a drive-by AI-sounding post, twenty-nine minutes after it appeared, and it is a fair objection to a specific behaviour rather than to the tools.

Put the whole record together and the pattern is narrow and useful. The complaints are not “the logic was wrong”. Least’s Copilot produced “really good functions” with persistence. DGCSCAD’s find-and-replace was “getting there”. The 2023 Autodesk community blog post on the subject closed with: “Overall I’m pretty impressed. I’m not sure this technology is going to take my drafting job yet, but I can definitely see it being an absolute asset for my productivity.”

The failures cluster somewhere specific: production hygiene. Error handler, undo group, system variable restore, local declaration, vl-load-com, quiet exit. Every one of those is a finishing step that a human adds after the routine already works — and a model handing you a finished-looking block of code has skipped the phase where those get added, because it never had a broken version to debug.

That is good news, because hygiene is checkable by eye in about ninety seconds. It does not require running anything. We have written the pass out as a line-by-line AutoLISP code review checklist, and the function allowlist handles the one failure mode reading cannot catch reliably.

One last thing, on the assumption that the vendor will solve this. AutoCAD 2027 shipped the Autodesk Assistant as a tech preview in March 2026. The launch post does not contain the words AutoLISP, LISP, script, macro or code — not once — and Autodesk bounds its scope in one sentence: “In this release, that capability is focused on alignment with CAD standards.” Nobody is coming to check your routines. That is still the red pen, and it is still yours.

If you want the wider context on driving AutoCAD from a model rather than pasting from a chat window, we covered that separately in Claude + AutoCAD via MCP. And the routines we actually ship are on the AutoLISP hub.

References

  1. Microsoft CoPilot AI can write AutoLisp coding — Autodesk Visual LISP, AutoLISP and General Customization Forum. Kent1Cooper 25 Oct 2024 and 15 Dec 2025; CodeDing 25 Oct 2024 and 15 Dec 2025; DGCSCAD 25 Oct 2024.
  2. Help with OpenAI ChatGPT generated Autolisp code — Autodesk forum. martti.halminen 14 Dec 2022; Kent1Cooper 13 Jan 2024; _gile 20 Mar 2024.
  3. How ChatGPT explained my Autolisp problem — Autodesk Civil 3D Customization Forum. hencoop (Henry C. Francis), 2 May 2023.
  4. AI taking over — CADTutor, AutoLISP, Visual LISP & DCL. Thread started by BIGAL, 19 June to 25 July 2026. Posts by Least, Danielm103, GLAVCVS, rlx, ryanatkins49056.
  5. Talking to AI about a Lisp — Autodesk community blog, TheCADnoob, 6 January 2023.
  6. Error Handling — Lee Mac. Localised *error* handler and the OSMODE restore pattern.
  7. About Using the *error* Function (AutoLISP) — Autodesk AutoLISP Developer’s Guide, AutoCAD 2024.
  8. About Undoing Changes Made by a Routine (AutoLISP) — Autodesk AutoLISP Developer’s Guide, AutoCAD 2024.
  9. OSMODE (System Variable) — Autodesk, AutoCAD 2024. Saved in: Registry; bitcode 16384.
  10. CLAYER (System Variable) — Autodesk, AutoCAD 2024. Saved in: Drawing.
  11. ORTHOMODE (System Variable) — Autodesk, AutoCAD 2024. Saved in: Drawing.
  12. CMDECHO (System Variable) — Autodesk, AutoCAD 2024. Saved in: Not-saved.
  13. About AutoLISP Compatibility — Autodesk CAD Management Guide, AutoCAD 2024. Obsolete commands and system variables, incl. BLIPMODE.
  14. About Local and Global Variables (AutoLISP) — Autodesk AutoLISP Developer’s Guide, AutoCAD 2024.
  15. To declare local variables (AutoLISP) — Autodesk AutoLISP Developer’s Guide, AutoCAD 2024.
  16. vl-load-com (AutoLISP/ActiveX) — Autodesk AutoLISP Reference, AutoCAD 2024. Supported platforms: Windows only.
  17. About Loading Extended AutoLISP Functions — Autodesk AutoLISP Developer’s Guide, AutoCAD 2024.
  18. What’s New or Changed with AutoLISP — Autodesk AutoCAD LT 2024 AutoLISP Developer’s Guide. LT ActiveX support and exclusion list; PROGRAM guard.
  19. Visual LISP IDE availability — Autodesk AutoCAD LT 2024 Help.
  20. command-s (AutoLISP) — Autodesk AutoLISP Reference, AutoCAD 2024. Supported platforms: Windows, Mac OS, and Web.
  21. About Exiting a Function Quietly (AutoLISP) — Autodesk AutoLISP Developer’s Guide, AutoCAD 2024.
  22. About System and Environment Variables (AutoLISP) — Autodesk AutoLISP Developer’s Guide, AutoCAD 2024. Invalid type supplied to setvar generates an AutoLISP error.
  23. AutoCAD 2027: Redefining How You Create, Collaborate, and Deliver — The AutoCAD Team, 25 March 2026. Autodesk Assistant tech preview scope.
  24. Using ChatGPT to Write AutoCAD LISP Routines: From Idea to Execution — Nick Turner, IMAGINiT, 3 October 2025.
  25. Claude + AutoCAD via MCP: AI Drafting on AutoLISP (2026 Guide) — blog.draftsperson.net.
  26. AutoLISP for AutoCAD: Tutorials and 139 Free Routines — blog.draftsperson.net.

Filed Under: AutoCAD Articles & Reference

Primary Sidebar

Subscribe to our Youtube Channel

Post CAD drafting jobs on Freelancer.com. and get some free money to do this.

Categories

  • American Steel Industry (4)
  • AutoCAD Articles & Reference (30)
  • AutoCAD Bugs & Problems (19)
  • AutoCAD Tips (29)
  • AutoCAD Tutorials (54)
  • AutoLISP Routines (328)
  • AutoLISP Tutorials (15)
  • CAD Standards (7)
  • Civil 3D (7)
  • Civil Drafting (4)
  • Dimensions (2)
  • Drafting Funnies (71)
  • Drafting History (9)
  • Drafting Standards (84)
  • Electrical Drafting (2)
  • General IT reference (7)
  • Geometry (15)
  • GIS (2)
  • Hatch Patterns (12)
  • Office Life Hacks (3)
  • PT (1)
  • Revit Tutorials (54)
  • Steel Detailing (14)
  • Structural Drafting (26)
  • Technical Dictionary (61)
  • Useful Website Links (19)

Footer

Free downloads

  • Free AutoLISP routines
  • Free hatch patterns
  • SHX fonts & text styles
  • Numbering LISP collection
  • ISO 3098B font

Reference charts

  • AWS weld symbols chart
  • Steel detailing chart
  • Hole & slot sizes
  • Bolt edge distance
  • ANSI & ARCH paper sizes
  • How to fold an A1 drawing

Useful links

  • CAD blocks (DWG)
  • Revit families
  • structuraldrafter.com
  • cad-corner.com
  • About
  • Privacy policy

Provided for free with no warranty · Log in