RecipesAutoLISP
Can AI write an AutoLISP routine and run it for me in AutoCAD?
Yes. Type "write a LISP that draws a centre mark on every circle on layer HOLES, run it, and tell me how many it did". cadssistant writes the routine, evaluates it directly in your AutoCAD session (no file to save, no APPLOAD), reads the return value back and replies with the count (say "and highlight them" to see the new entities gripped). If the expression errors it sees the message, corrects the routine and runs it again. Every expression it evaluates is shown in the chat with the value that came back. To keep the routine, say "show me the code as a .lsp I can load".
Checked 2026-10-30
write a LISP that draws a centre mark on every circle on layer HOLES, run it, and tell me how many it did
What cadssistant does
- Writes the routine as one AutoLISP form (a progn with a repeat loop) and evaluates it in the open drawing, which returns the value.
- Checks the value: the count of marks, or an error message. An error goes back into the next attempt; you don't carry it by hand.
- Replies with the count; the expression it ran stays visible in the chat. Say "highlight them" and it grips the new entities so you can see them. Ask for it as a file-ready defun to keep it.
The same task in AutoLISP
(progn
(setq ss (ssget "_X" '((0 . "CIRCLE") (8 . "HOLES"))) i 0 n 0)
(if ss
(repeat (sslength ss)
(setq ed (entget (ssname ss i)) i (1+ i)
c (cdr (assoc 10 ed)) k (* 1.25 (cdr (assoc 40 ed))))
(entmake (list '(0 . "LINE") (cons 10 (polar c pi k)) (cons 11 (polar c 0.0 k))))
(entmake (list '(0 . "LINE") (cons 10 (polar c (* 1.5 pi) k)) (cons 11 (polar c (* 0.5 pi) k))))
(setq n (1+ n))))
n)Two lines through each centre, 1.25 × radius long each side, on the current layer. Returns the number of circles marked.
Good to know
- Ask for a count or a summary rather than a dump of every entity: a short answer is easier to check, and a very long one is cut short.
More in autolisp
Command: CADSSISTANT
Works in AutoCAD 2024 and newer on Windows. Free trial, no card, no API key.
Get cadssistant