Function Syntax: SwapBlockAssignLayer Version: 1.1 Date: 20.06.2026 6:38:49PM AI+https://www.cadtutor.net/forum/topic/21571-replace-selected-block-or-blocks-with-another-block/ Description 🚀 SwapBlockAssignLayer is an AutoCAD AutoLISP utility for replacing selected drawing objects with instances of an existing named block from the current drawing. The tool helps CAD users convert temporary geometry, placeholder symbols, or manually drafted objects into standardized block references for cleaner AutoCAD and Civil 3D drawings. Command 🧩 Run SwapBlockAssignLayer in the AutoCAD command line. The routine asks the user to select the objects to replace, then opens a DCL block-selection dialog. Functionalities 🔎 Object selection workflow - prompts the user to select drawing entities that should be replaced by block references. 📋 Named block scanner - reads the drawing block table and lists available user-defined blocks. 🚫 Anonymous block filtering - skips anonymous and system block definitions whose names begin with an asterisk. 🪟 DCL dialog selection - creates a temporary dialog named DuplicateToBlockInsert with a popup list of available blocks. 💾 Last block memory - stores the last used block in DuplicateToBlockInsert_LastBlock and preselects it on the next run. 📍 Insertion point detection - uses the selected object's insertion point when available. 📐 Bounding-box fallback - calculates the object center from its bounding box when an insertion point is not available. 🧭 UCS-aware rotation - inserts the replacement block using the current UCS X direction for rotation. 🧹 Cleanup replacement - deletes the original selected object after inserting the new block reference. Technical Notes ⚙️ The code uses tblnext, ssget, vlax-ename->vla-object, vla-GetBoundingBox, vla-InsertBlock, and vla-Delete. ⚠️ The uploaded code does not explicitly assign the inserted block reference to the original entity layer, even though the file name includes AssignLayer. ⚠️ Test on a copy of the drawing because the original selected entities are deleted after replacement. Practical Result ✅ Selected drawing objects are converted into consistent block references, placed at each object's insertion point or bounding-box center, helping standardize CAD content and reduce manual block replacement work. Tags 🏷️ AutoCAD, 🏷️ AutoLISP, 🏷️ Civil 3D, 🏷️ Block Replacement, 🏷️ DCL Dialog, 🏷️ Drawing Cleanup, 🏷️ CAD Automation