Skip to content

Instantly share code, notes, and snippets.

@lwilks
lwilks / extract-bound-xrefs.lsp
Last active October 20, 2025 09:10
AutoLISP script to extract former external reference names from bound blocks in AutoCAD DWG files. [FIXED] Now uses ObjectDBX for stable batch processing - no more crashes! Includes enhanced error handling and multiple methods for file discovery on OneDrive paths.
;;; extract-bound-xrefs.lsp
;;; Extracts names of former external references that have been bound as blocks
;;; Works on single or multiple DWG files
(defun C:EXBX (/ blocks block-name xref-names)
"Extract Bound Xrefs - Single file version"
(princ "\n--- Extracting Bound Xref Names ---\n")
(setq xref-names (get-bound-xref-names))
(if xref-names
@lwilks
lwilks / replace-block.lsp
Last active August 6, 2025 04:56
AutoCAD script to replace blocks with another block from a specified path
;; AutoCAD LISP function to replace blocks with same name
;; Usage for CLI: (REPLACEBLOCK-CLI "BLOCKNAME" "C:\\Path\\To\\Block.dwg")
;; Usage interactive: REPLACEBLOCK
(defun REPLACEBLOCK-CLI (blockName blockPath / oldBlockName newBlockPath blockExists ss i n ent entData insPoint xScale yScale zScale rotation layer oldInsunits oldInsunitsdefsource oldInsunitsdeftarget oldAttreq oldFiledia oldCmdecho instanceList)
(setq oldBlockName blockName)
(setq newBlockPath blockPath)
(if (and oldBlockName newBlockPath (/= oldBlockName "") (/= newBlockPath ""))
(progn