Microsoft CoPilot AI can write AutoLisp coding

Microsoft CoPilot AI can write AutoLisp coding

chlaksavery
Observer Observer
3,036 Views
6 Replies
Message 1 of 7

Microsoft CoPilot AI can write AutoLisp coding

chlaksavery
Observer
Observer

It's not perfect. Sometimes theses a back and forth to correct and error check. But the AI will try to fix the code until it does work.

Last thing I tried was asking it to write code to convert all survey figures to polylines at a zero elevation.

Took a few fixes, but eventually worked. Now it's a Button Macro. https://omegle.onl/

3,037 Views
6 Replies
Replies (6)
Message 2 of 7

kczerwonka
Advocate
Advocate

Never thought of doing that. That's cool!

0 Likes
Message 3 of 7

Kent1Cooper
Consultant
Consultant

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....

Kent Cooper, AIA
0 Likes
Message 4 of 7

CodeDing
Advisor
Advisor

@chlaksavery ,

 

I have personally found recently that Claude.ai is better at writing code than ChatGPT. Might be worth looking into.

 

Also, I created a SF2 command to do the exact thing you requested (converting Survey Figures). You can get it from this post here:

https://forums.autodesk.com/t5/civil-3d-forum/database-processing-feature-lines-instead-of-survey-fi... 

 

Best,

~DD

0 Likes
Message 5 of 7

DGCSCAD
Collaborator
Collaborator

After seeing this thread, I took a crack at having it emulate a no-frills version of ACAD's native Find And Replace Text. A few tweaks later and it's getting there, but it's still a WIP:

 

(defun c:FART (/ ss find replace);Find And Replace Text
  (setq find (getstring "\nEnter the text to find: "))
  (setq replace (getstring "\nEnter the replacement text: "))
  (setq ss (ssget '((0 . "TEXT,MTEXT,DIMENSION,ACAD_TABLE"))))
  (if ss
    (progn
      (vlax-for obj (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))
(princ "\n")
(princ (vla-get-ObjectName obj))
        (cond
          ((= (vla-get-ObjectName obj) "AcDbText")
           (while (vl-string-search find (vla-get-TextString obj))
             (vla-put-TextString obj (vl-string-subst replace find (vla-get-TextString obj)))))
          ((= (vla-get-ObjectName obj) "AcDbMText")
           (while (vl-string-search find (vla-get-TextString obj))
             (vla-put-TextString obj (vl-string-subst replace find (vla-get-TextString obj)))))
          ((= (vla-get-ObjectName obj) "AcDbRotatedDimension")
           ;(if (vl-string-search find (vla-get-TextOverride obj))
           (while (vl-string-search find (vla-get-TextOverride obj))
             (vla-put-TextOverride obj (vl-string-subst replace find (vla-get-TextOverride obj)))))
          ((= (vla-get-ObjectName obj) "AcDbTable")
           ;(let ((rowCount (vla-get-Rows obj))
                 ;(colCount (vla-get-Columns obj)))

		(setq colCount (vlax-get-property obj 'Columns))
		(setq rowCount (vlax-get-property obj 'rows))

             (repeat rowCount
               (setq row (1- rowCount))
               (repeat colCount
                 (setq col (1- colCount))
                 (setq cellText (vla-gettext obj row col))
                 (while (vl-string-search find cellText)
                   (setq cellText (vl-string-subst replace find cellText))
                   (vla-SetText obj row col cellText))
                 (setq colCount (1- colCount)))
               (setq rowCount (1- rowCount)))));)
        )
      (princ "\nText replacement completed.")
    )
    (princ "\nNo matching text found.")
  )
  (princ)
)

 

I had it add MLeaders, but that was full of made-up function definitions. I'll be trying a different approach.

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Message 6 of 7

gbattinPH5TG
Advocate
Advocate
What a great command for a tool. LOL
Have AI add a prompt at the end that says (princ "\nFART has finished successfully.")
Message 7 of 7

Sea-Haven
Mentor
Mentor

For anyone with Copilot make sure last 2 words are "Autocad lisp", but it can struggle on some tasks.

0 Likes