As for the AutoCAD LISP with ChatGPT, I’m going to explain later, and I’ll try it blindly. I have drawn various objects for the example below.
I could code more succinctly and rationally now, but here’s a LISP program I made 20 years ago to deal with a situation similar to the example. The contents are as follows.
(defun c:change_string () (setq gets (ssget (list (cons 0 "TEXT")))) (setq str_list nil) (setq n 0) (repeat (sslength gets) (setq a (ssname gets n)) (setq b (cdr (assoc 62 (entget a)))) (if (= 2 b) (progn (setq c (cdr (assoc 1 (entget a)))) (setq d (strcat c "-1")) (entmod (subst (cons 1 d) (cons 1 c) (entget a))) (setq n (1 n)) ) ; end of progn (progn (setq n (1 n)) ) ; end of progn ) ; end of if ) ; end of repeat ) ; end of defun
Change_String
A simple LISP program that filters only yellow text and appends “-1” to the end. In the same way as this, I asked ChatGPT to write LISP coding. The prompt is:
Please make a LISP program for AutoCAD. The order of operations can be seen below;
1. When selecting objects with ‘select window’, only text objects are automatically filtered and selected. 2. Among the selected text objects, only yellow text objects are saved as a list. 3. Insert “-1” at the end of the string of text objects stored in the list. 4. Close the program.
;; Step 2: Save the yellow text objects in a list (setq yellow_texts (mapcar 'vlax-vla-object->ename filtered_objs))
;; Step 3: Insert "-1" at the end of the string of text objects (foreach obj yellow_texts (setq text_obj (vlax-ename->vla-object obj)) (setq modified_text (strcat (vla-get-textstring text_obj) "-1")) (vla-put-textstring text_obj modified_text) )
;; Step 4: Close the program (princ "Program finished. Yellow text objects updated.") (princ) )
FilterYellowText
As a professional engineer, I am constantly amazed by the power of Artificial Intelligence and its potential to transform the way we work. Among the numerous AI breakthroughs, OpenAI’s ChatGPT has emerged as an invaluable tool for software developers and engineers alike.
LISP, a powerful and expressive programming language, has been at the core of AutoCAD customization for decades. It enables engineers to create tailored solutions that streamline their workflows and enhance productivity. However, developing efficient LISP programs can be time-consuming, especially for those with limited programming experience.
Enter ChatGPT, an AI-driven language model with an uncanny ability to understand and generate human-like text. Its exceptional capabilities have proven invaluable for engineering tasks, including the development of LISP programs for AutoCAD. Within this article, I will demonstrate how ChatGPT can generate effective LISP code in response to specific requirements, all within a mere 1000 letters.
Recently, I presented ChatGPT with a challenge to develop a LISP program for AutoCAD, with a specific set of operations: filtering text objects by color, appending a suffix to the text, and closing the program. Remarkably, ChatGPT generated two different yet functional LISP programs that successfully executed the required tasks.
These programs showcase ChatGPT’s ability to comprehend complex engineering requirements and deliver practical solutions within a concise character limit. Engineers can leverage ChatGPT’s capabilities to quickly develop LISP programs, minimize the time spent on customization, and increase their overall efficiency.
Conclusion
In conclusion, ChatGPT is not just an innovative AI technology; it is a powerful ally for engineers seeking to revolutionize their workflows with bespoke LISP solutions. The potential applications of ChatGPT extend far beyond AutoCAD, promising to reshape the landscape of software development and engineering as we know it. Embrace the power of AI, and reimagine what is possible with ChatGPT by your side.
12 Comments Add yours