Prompt Details
Model
(claude-5-sonnet)
Token size
1,034
Example input
[TASK]: Insert a numbered bubble (circle + incrementing number) at each point I click, on layer BUBBLES
[ACADVERSION]: AutoCAD 2024
[UNITS]: mm
[COMMANDNAME]: BUBBLE
[EXTRADETAILS]: circle radius 5 mm, text height 3 mm, start number 1
Example output
1. ASSUMPTIONS
Layer BUBBLES is created if it does not already exist. Numbers are placed as single-line text, centered on the picked point. No assumptions needed - all inputs were provided.
2. AUTOLISP CODE
```lisp
;; BUBBLE - place numbered detail bubbles at each picked point
;; Draws a circle on layer BUBBLES with a centered, incrementing number
(defun c:BUBBLE ( / oldcmd oldosm oldlay pt num rad tht lay)
;; local error handler: restore saved settings, close undo group
(defun *error* (msg)
(if oldcmd (setvar "cmdecho" oldcmd))
(if oldosm (setvar "osmode" oldosm))
(if oldlay (setvar "clayer" oldlay))
(command "_.undo" "_end")
(if (and msg (not (wcmatch (strcase msg) "*CANCEL*,*QUIT*")))
(princ (strcat "\nError: " msg)))
(princ))
;; save the settings we are about to change
(setq oldcmd (getvar "cmdecho")
oldosm (getvar "osmode")
oldlay (getvar "clayer")
rad 5.0 ; circle radius (mm)
tht 3.0 ; text height (mm)
num 1 ; starting number
lay "BUBBLES")
(setvar "cmdecho" 0)
(command "_.undo" "_begin")
;; create the target layer if missing, then make it current
(if (not (tblsearch "layer" lay))
(command "_.-layer" "_make" lay ""))
(setvar "clayer" lay)
;; loop until the user presses Enter instead of picking a point
(while (setq pt (getpoint "\nPick bubble point <Enter to stop>: "))
(command "_.circle" pt rad)
(command "_.-text" "_j" "_m" pt tht 0 (itoa num))
(setq num (1+ num)))
;; restore everything we changed
(setvar "clayer" oldlay)
(setvar "osmode" oldosm)
(setvar "cmdecho" oldcmd)
(command "_.undo" "_end")
(princ))
(princ "\nType BUBBLE to place numbered bubbles.")
(princ)
```
3. HOW TO LOAD
Type APPLOAD, browse to this .lsp file, click Load, then Close (or drag the file into the drawing window). You now have the command BUBBLE.
4. HOW TO USE
Type BUBBLE and press Enter, then click each point you want a bubble at. Press Enter to finish. Example: three clicks give you circles numbered 1, 2, 3 on layer BUBBLES.
5. VERIFIED
Command defined as c:BUBBLE - PASS
All variables localised - PASS
*error* handler restores system variables - PASS
Undo group present - PASS
User-cancel handled - PASS
By purchasing this prompt, you agree to our terms of service
CLAUDE-5-SONNET
Turn a plain-language request into a ready-to-load AutoLISP routine for AutoCAD - no coding needed. Describe the task, your AutoCAD version, units, a command name, and any layer or size rules, and get clean commented .lsp code with a built-in error handler, undo support, and clear load and usage steps. Great for drafters and CAD managers automating repetitive work. Missing details get a short assumptions note, and a built-in self-check confirms the code is solid before you load it.
...more
Added 1 week ago
