How to Use ChatGPT to Create AutoLISP Code for AutoCAD | Automate Drafting | Easily 2026
By Impran M N
AutoLISP is the scripting language behind most AutoCAD automation, but learning its syntax just to speed up one repetitive drafting task is a hard sell for most designers who'd rather be drafting than debugging parentheses. ChatGPT closes that gap: describe what you want to happen to a selected object or set of objects, and it writes a working routine, complete with plain-language instructions for loading it into AutoCAD.
This isn't limited to simple property changes either — the same approach scales to batch renaming, layer management, and other repetitive edits that would otherwise eat up a chunk of every project. This guide follows that exact path — from a plain-English request through to a saved .lsp file running inside AutoCAD — using a real example ChatGPT produced: a command that recolors selected objects to red.
01Describe the task in plain language, not code
Open a ChatGPT conversation and describe the drafting action you want automated the same way you'd explain it to a colleague — for example, "create an AutoLISP code that changes a selected object to red." You don't need to know AutoLISP syntax, function names, or color index numbers going in. The more specific you are about the trigger and the result, the less back-and-forth you'll need afterward, so mention things like whether the command should work on one object or a whole selection set, and whether it needs to run once or be repeatable within the same session without reloading. If your drafting task depends on a specific AutoCAD version or a plugin you're already using, mention that too, since AutoLISP behavior can vary slightly across versions.
02Let ChatGPT generate the routine and read the instructions it gives you
ChatGPT returns a formatted code block along with a numbered "How to use" section underneath it — in this example, five steps covering saving the file, loading it with the APPLOAD command, and running it by typing RED. This is the part worth reading carefully before you touch AutoCAD at all, since it tells you the exact command name the script defines and what happens when you run it, without you having to reverse-engineer the code yourself. In this case, ChatGPT even offered an alternative version further down the response using ActiveX instead of the CHPROP command, noting it's generally faster — a good reminder that it's worth scrolling past the first code block if the response continues, since a second option might fit your setup better.

03Understand what the code actually does
In this example, the routine defines a new command called RED using defun, prompts you to select objects, and then applies AutoCAD's CHPROP command to change the selected objects' color to color index 1, which is red. It also includes basic handling for when no objects are selected, so the command fails gracefully instead of erroring out with a cryptic message. You don't have to be able to write this from scratch, but skimming it for the command name and what it touches is worth the extra minute before you load anything into a live drawing — specifically, look for which AutoCAD command it's calling internally (CHPROP here) and what property it's changing, since that tells you the actual scope of what will happen when you run it.
04Save the code as a .lsp file
Copy the code block out of ChatGPT and paste it into a plain text editor — Notepad works fine, since AutoLISP files are just text with a .lsp extension. Save the file with a name that matches the command it defines, like RED.lsp, in a folder you'll remember, ideally one dedicated folder for all your custom routines rather than scattering them across project directories. Keeping the filename aligned with the command name isn't required by AutoCAD, but it saves you from second-guessing which file does what once you've generated a few of these, especially if you build up a small personal library of automation scripts over time.

05Load the routine into AutoCAD
In AutoCAD, type APPLOAD at the command line, which opens a dialog for browsing to and loading LISP files. Navigate to the .lsp file you just saved and load it. AutoCAD doesn't automatically load custom LISP files on startup, so you'll repeat this step each new session unless you set it up to load automatically through the same dialog's startup suite option, which is worth doing once you've confirmed a routine works and expect to use it regularly across multiple projects.
06Run the new command on a test drawing first
With the file loaded, type the command name ChatGPT defined — RED, in this example — press enter, select your objects, and confirm the result matches what you expected. Run this on a throwaway or duplicate drawing the first time, not a live project file, since AI-generated scripts should always be verified against your actual CAD environment before you trust them on real work. Test with a mix of object types if your routine is meant to work broadly — a script that behaves correctly on a simple line might handle a block reference or a hatch pattern differently, and it's better to find that out on a test file than partway through a real project.
07Refine it with follow-up prompts
If the routine doesn't do quite what you need — wrong color, wrong scope, missing a confirmation step — go back to the same ChatGPT conversation and describe the adjustment directly, like changing the color index or adding a prompt before applying changes. ChatGPT retains the context of what it already wrote, so revisions come back faster than starting a fresh request, and you can keep iterating until the command does exactly what your workflow needs.
Frequently asked questions
Do I need to know AutoLISP to use this method?
No. You describe the drafting task in plain language and ChatGPT writes the AutoLISP code, including a command name and usage instructions. Understanding the basics of what the code does helps, but writing it yourself isn't required.
How do I load a ChatGPT-generated .lsp file into AutoCAD?
Save the code from ChatGPT into a text file with a .lsp extension, then in AutoCAD type APPLOAD and browse to that file. AutoCAD needs the file loaded each session unless you add it to the startup suite.
Is it safe to run AI-generated AutoLISP code directly on a project file?
Test it on a non-critical or duplicate drawing first. AI-generated scripts can behave unexpectedly, so confirming the result matches what you intended before using it on real project work is worth the extra few minutes.
What if the generated command doesn't do exactly what I need?
Describe the specific adjustment back to ChatGPT in the same conversation — it keeps the context of the original code and can revise it, which is faster than writing a brand-new prompt from scratch.
What kinds of AutoCAD tasks work well with this approach?
Repetitive actions applied to selected objects — changing properties like color or layer, running a batch operation, or automating a multi-step edit — are good candidates, since they're the tasks costing the most manual, repetitive time in a typical drafting session.
Watch the full walkthrough
The same steps, demonstrated on screen from start to finish.



