AutoCAD 2015 and AutoCAD LT 2015 Bible

The most comprehensive AutoCAD book around!

How to use Chat GPT to create AutoCad lisp

Using ChatGPT to create AutoLISP scripts for AutoCAD can be an effective way to streamline your design process. AutoLISP is a dialect of the programming language LISP (List Processing language) that’s used specifically for Autodesk’s AutoCAD software.

Here’s a general guide on how you could use ChatGPT to create AutoCAD Lisp:

1. Define Your Objective:

Clarify what you want the AutoLISP script to do. Maybe you want it to automate a certain repetitive task, or perhaps you need it to extract specific information from your AutoCAD drawings.

2. Consult ChatGPT:

Engage with the AI, explaining your objective as clearly as possible. For example, you might say, “I want to create an AutoLISP script that will count the number of blocks in an AutoCAD drawing.”

3. Extract the Information:

ChatGPT will then provide you with information based on its extensive knowledge. It could give you step-by-step instructions, relevant coding examples, or even potential code snippets.

Here’s an example of how this interaction might look:

You: I want to create a LISP script to count the number of blocks in an AutoCAD drawing.

ChatGPT: Sure. Here’s a basic example of how you might do that:

(defun c:countblocks (/ sset numblocks)
  (setq sset (ssget "X" '((0 . "INSERT"))))
  (setq numblocks (sslength sset))
  (alert (strcat "Number of Blocks: " (itoa numblocks)))

In this script, ssget is used with a filter to select all block insertions in the drawing. sslength then determines the length of the selection set, which is the number of blocks. Finally, alert displays this number in a dialog box.

Remember to load your LISP script into AutoCAD to make the new command (in this case, countblocks) available.

4. Refine the Code:

After receiving the information from ChatGPT, you may need to refine and adjust the code to better suit your specific needs. If you need help with this, you can ask ChatGPT for more assistance.

5. Test and Iterate:

Once you have your AutoLISP code, load it into AutoCAD and test it. If it doesn’t work as expected or if you encounter any errors, you can refer back to ChatGPT for troubleshooting advice.

Remember, creating AutoLISP scripts can be complex, especially for more sophisticated tasks. Don’t be discouraged if you don’t get it right the first time. With practice and the assistance of ChatGPT, you’ll get the hang of it very soon.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>