Jump to content

LLM-based Autocad automation


Dmytro

Recommended Posts

Hi everyone,

 

I would like to share a small open-source prototype of an LLM-based AutoCAD automation tool.

 

This is a .Net plugin, that generates other .Net plugins for autocad based on a user prompt :)

 

Here you can find a short demo of the plugin:

 

 

 

 

Here you can find the sources (and installer to try it yourself): https://github.com/dimitrovakulenko/Scripture

 

I'd love to hear your feedback and ideas! Feel free to share your thoughts in the comments below.

Link to comment
Share on other sites

How does it compare to ChatGP and MS Pilot ? Providing the same code ? 

 

COPILOT

"Make 12 random objects line circle pline in model space within bounds 0,0 1000,1000. Using Autocad lisp" The result was so close missing a closing ).

 

(defun c:RandomObjects ()
  (defun random-point (min max)
    (list (+ min (random (- max min))) (+ min (random (- max min)))))
  (defun random-radius (min max)
    (+ min (random (- max min))))
  (defun create-random-line ()
    (entmake
      (list
        (cons 0 "LINE")
        (cons 10 (random-point 0 1000))
        (cons 11 (random-point 0 1000)))))
  (defun create-random-circle ()
    (entmake
      (list
        (cons 0 "CIRCLE")
        (cons 10 (random-point 0 1000))
        (cons 40 (random-radius 10 50)))))
  (defun create-random-polyline ()
    (entmake
      (append
        (list (cons 0 "LWPOLYLINE") (cons 90 4))
        (mapcar
          '(lambda (pt) (cons 10 pt))
          (list (random-point 0 1000) (random-point 0 1000) (random-point 0 1000) (random-point 0 1000))))))
  (repeat 4 (create-random-line))
  (repeat 4 (create-random-circle))
  (repeat 4 (create-random-polyline))
  (princ "\n12 random objects created in model space.")
  (princ)
)
(c:RandomObjects)

 

Link to comment
Share on other sites

The prototype allows usage of different models.

I've used it with chatGPT 4.0o deployed via Azure. (You can also use your model from open ai directly).

With some minor code adjustments it would be possible to try other models as well, i.e. mistral, ollama, etc.

 

The strength of this prototype is the implemented workflow: we ask LLM to generate a script, we try to compile it on fly (don't know if this can be done with lisp, dotnet Roslyn API allows to do that for csharp), if a script cannot be compiled we make another request(s) to LLM to try fix the script based on errors reported by compiler. Fixing process is done in a loop. This way I guarantee the generated script can actually be compiled.

The script itself might not solve the problem perfectly, cause it is just a generated by LLM, that can hallucinate.

 

Step2 is supposed to allow fine-tuning of the script. Step-2 is very simple now: allows manual editing and automatic fixing by providing more context to an LLM.

 

Please check out the state machine diagram on project GitHub page to better understand what I've just tried to explain.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...