Grouping raw geometry into blocks in AutoCAD is something designers do dozens of times a day. However, using the native BLOCK command breaks your drafting momentum: you have to stop to brainstorm a unique block name, set an exact insertion point, pick objects, and click through confirmation dialogs. Doing this repeatedly for minor drawing groups is a huge time sink.
The SQB.lsp (Quick Block Creator) utility completely removes those repetitive steps. It automatically generates a unique time-stamped block name, calculates the exact geometric center of your selection if you skip picking a base point, and converts your selected geometry into an in-place block reference in less than a second.
Why SQB.lsp Speeds Up Block Creation
Zero Name Typing: Generates a secure, randomized hexadecimal block name (e.g.,
A$C1A2B3C) automatically, so you never have to brainstorm temporary block names again.Smart Auto-Center Snap: Simply press Enter without picking a base point, and the script instantly calculates the precise geometric bounding box center of your selected objects.
Instant In-Place Replacement: Replaces selected raw lines, arcs, and polylines with the newly created block reference at the exact same drawing location in one smooth motion.
Step-by-Step Instructions
Load
SQB.lspin AutoCAD using theAPPLOADcommand.Type
SQBin the command prompt and hit Enter.Select all the geometry elements you want to turn into a block, then press Enter.
Choose your base point:
Click a specific point on screen for a custom insertion base point.
Or simply press Enter / Spacebar to let the script automatically calculate the exact geometric center.
Your objects are instantly grouped into a uniquely named block and inserted back in place.
AutoLISP Code (SQB.lsp)
Copy the code below and save it as SQB.lsp inside your AutoCAD support folder:
(vl-load-com)
(defun c:SQB ( / *error* ss pt n h name oldos oldecho oldhigh undoflag i ent obj minpt maxpt minL maxL minx miny maxx maxy )
(defun *error* (msg)
(if oldos (setvar "osmode" oldos))
(if oldecho (setvar "cmdecho" oldecho))
(if oldhigh (setvar "highlight" oldhigh))
(if undoflag
(if (vl-symbol-value 'command-s)
(command-s "_.undo" "_end")
(command "_.undo" "_end")
)
)
(princ "\nCAD Lisp [www.daolpro.com]")
(princ)
)
(setq oldos (getvar "osmode"))
(setq oldecho (getvar "cmdecho"))
(setq oldhigh (getvar "highlight"))
(setq undoflag nil)
(setvar "cmdecho" 0)
(setq ss (ssget))
(if ss
(progn
(command "_.undo" "_begin")
(setq undoflag T)
(setq pt (getpoint "\nSpecify insertion base point (Center of objects): "))
(setvar "osmode" 0)
(setvar "highlight" 0)
(if (null pt)
(progn
(setq i (sslength ss) minx nil miny nil maxx nil maxy nil)
(while (> i 0)
(setq ent (ssname ss (setq i (1- i))))
(setq obj (vlax-ename->vla-object ent))
(if (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getBoundingBox (list obj 'minpt 'maxpt))))
(progn
(setq minL (vlax-safearray->list minpt)
maxL (vlax-safearray->list maxpt))
(setq minx (if minx (min minx (car minL)) (car minL))
miny (if miny (min miny (cadr minL)) (cadr minL))
maxx (if maxx (max maxx (car maxL)) (car maxL))
maxy (if maxy (max maxy (cadr maxL)) (cadr maxL)))
)
)
)
(if (and minx miny maxx maxy)
(setq pt (list (/ (+ minx maxx) 2.0) (/ (+ miny maxy) 2.0) 0.0))
)
)
)
(if pt
(progn
(setq n (fix (* (- (getvar "DATE") (fix (getvar "DATE"))) 100000000))
h "0123456789ABCDEF"
name "A$C")
(if (= n 0) (setq n 98765432))
(while (> n 0)
(setq name (strcat name (substr h (1+ (rem n 16)) 1))
n (/ n 16))
)
(command "_.-block" name pt ss "")
(command "_.-insert" name pt "" "" "")
(setvar "osmode" oldos)
(setvar "highlight" oldhigh)
(setvar "cmdecho" oldecho)
(command "_.undo" "_end")
(princ (strcat "\nBlock \"" name "\" created successfully."))
(princ "\nCAD Lisp [www.daolpro.com]")
)
(progn
(setvar "osmode" oldos)
(setvar "highlight" oldhigh)
(setvar "cmdecho" oldecho)
(if (vl-symbol-value 'command-s)
(command-s "_.undo" "_end")
(command "_.undo" "_end")
)
(princ "\nFailed to calculate center point.")
(princ "\nCAD Lisp [www.daolpro.com]")
)
)
)
(progn
(setvar "cmdecho" oldecho)
)
)
(princ)
)
Efficiency Tip
When organizing temporary detail groups during drawing reviews, use SQB.lsp to convert loose linework into blocks quickly without worrying about duplicate block name conflicts. If you need to standardize block names later, you can rename them with

Post a Comment