Discovering halfway through a project that a block’s insertion point was set to an arbitrary coordinate is a common CAD frustration. Fixing it natively in the Block Editor usually turns into a headache: once you redefine the origin, every existing instance of that block across your drawing jumps out of position, forcing you to spend time moving dozens of blocks back where they belong.
The BBS.lsp (Block Base Set) utility fixes misaligned block insertion points in two clicks without moving your geometry on screen. It automatically updates the block definition origin while re-calculating position matrices to keep every existing block instance stationary in your drawing.
Key Workflow Advantages
Zero Entity Displacement: Updates the block's internal origin point while automatically holding all placed blocks at their exact screen coordinates.
Automatic Attribute Sync: If your block contains attribute tags, the script automatically executes an
ATTSYNCpass to keep tag alignment clean.Drawing-Wide Origin Update: Eliminates the need to open Block Editor (
BEDIT) or manually adjust block positions after redefining origins.
Step-by-Step Instructions
Load
BBS.lspinto AutoCAD using theAPPLOADcommand.Type
BBSin the command line and hit Enter.Select the block whose base point you want to redefine.
Click the exact location on screen where you want the new base point to be located.
The script recalculates insertion coordinates, updates all placed block instances drawing-wide, syncs attributes, and performs a workspace refresh (
REGEN).
AutoLISP Code (BBS.lsp)
Copy the code below and save it as BBS.lsp inside your AutoCAD support folder:
(defun c:BBS ( / *error* acDoc oldecho oldosmode ent vla-ent blkName pt_new pt_wcs pt_ins wcs_disp v_ocs i_ang ang x y r_x r_y pt_local blkObj old_origin ss i inst vla-inst idx_dxf i_scaleX i_scaleY i_scaleZ idx_ang ix iy i_pt_scaled i_pt_rotated i_pt_ins i_pt_ocs_new)
(vl-load-com)
(setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq oldecho (getvar "CMDECHO")
oldosmode (getvar "OSMODE"))
(defun *error* (msg)
(if oldecho (setvar "CMDECHO" oldecho))
(if oldosmode (setvar "OSMODE" oldosmode))
(vla-EndUndoMark acDoc)
(princ "\nCAD Lisp [www.daolpro.com]")
(princ)
)
(setvar "CMDECHO" 0)
(vla-StartUndoMark acDoc)
(setq ent (car (entsel "\nSelect a block to change its insertion point: ")))
(if ent
(progn
(setq idx_dxf (entget ent))
(if (= (cdr (assoc 0 idx_dxf)) "INSERT")
(progn
(setq vla-ent (vlax-ename->vla-object ent)
blkName (vlax-get-property vla-ent 'EffectiveName)
pt_new (getpoint "\nSpecify new base point: "))
(if pt_new
(progn
(setq pt_wcs (trans pt_new 1 0)
pt_ins (trans (cdr (assoc 10 idx_dxf)) ent 0)
wcs_disp (mapcar '- pt_wcs pt_ins)
v_ocs (trans wcs_disp 0 ent 1)
i_ang (cdr (assoc 50 idx_dxf))
ang (- i_ang)
x (car v_ocs)
y (cadr v_ocs)
r_x (- (* x (cos ang)) (* y (sin ang)))
r_y (+ (* x (sin ang)) (* y (cos ang)))
i_scaleX (cond ((cdr (assoc 41 idx_dxf))) (1.0))
i_scaleY (cond ((cdr (assoc 42 idx_dxf))) (1.0))
i_scaleZ (cond ((cdr (assoc 43 idx_dxf))) (1.0))
pt_local (list (/ r_x i_scaleX) (/ r_y i_scaleY) (/ (caddr v_ocs) i_scaleZ))
blkObj (vla-item (vla-get-Blocks acDoc) blkName)
old_origin (vlax-safearray->list (vlax-variant-value (vla-get-origin blkObj))))
(vla-put-origin blkObj (vlax-3d-point (mapcar '+ old_origin pt_local)))
(if (setq ss (ssget "X" '((0 . "INSERT"))))
(progn
(setq i (sslength ss))
(while (> i 0)
(setq i (1- i))
(setq inst (ssname ss i)
vla-inst (vlax-ename->vla-object inst))
(if (= (vlax-get-property vla-inst 'EffectiveName) blkName)
(progn
(setq idx_dxf (entget inst)
i_scaleX (cond ((cdr (assoc 41 idx_dxf))) (1.0))
i_scaleY (cond ((cdr (assoc 42 idx_dxf))) (1.0))
i_scaleZ (cond ((cdr (assoc 43 idx_dxf))) (1.0))
idx_ang (cond ((cdr (assoc 50 idx_dxf))) (0.0))
i_pt_scaled (list (* (car pt_local) i_scaleX) (* (cadr pt_local) i_scaleY) (* (caddr pt_local) i_scaleZ))
ix (car i_pt_scaled)
iy (cadr i_pt_scaled)
i_pt_rotated (list (- (* ix (cos idx_ang)) (* iy (sin idx_ang))) (+ (* ix (sin idx_ang)) (* iy (cos idx_ang))) (caddr i_pt_scaled))
i_pt_ins (cdr (assoc 10 idx_dxf))
i_pt_ocs_new (mapcar '+ i_pt_rotated i_pt_ins)
idx_dxf (subst (cons 10 i_pt_ocs_new) (assoc 10 idx_dxf) idx_dxf))
(entmod idx_dxf)
(entupd inst)
)
)
)
)
)
(if (= (vla-get-HasAttributes vla-ent) :vlax-true)
(vl-cmdf "._ATTSYNC" "_Name" blkName "_Yes")
)
(vl-cmdf "._REGEN")
(princ (strcat "\nSuccess: Base point for block '" blkName "' updated."))
)
(princ "\nCommand cancelled.")
)
)
(princ "\nError: Selected object is not a block.")
)
)
(princ "\nCommand cancelled.")
)
(vla-EndUndoMark acDoc)
(setvar "CMDECHO" oldecho)
(setvar "OSMODE" oldosmode)
(princ "\nCAD Lisp [www.daolpro.com]")
(princ)
)
Block Management Tip
When redefining block insertion points in drawings with complex nested blocks or rotated components, running BBS directly ensures all global coordinates remain locked in place while fixing rotation anchors for future inserts.

Post a Comment