Function Syntax: ExtractFromBlock / DeleteObjectFromBlock Version: 1.0 Date: 20.06.2026 6:38:48PM N/A short_description: | SEO Short Description 🚀 DeleteObjectFromBlock is an AutoCAD AutoLISP and DCL utility for extracting or deleting nested objects from block definitions directly from the drawing editor. It helps CAD users clean block content, move nested geometry back to model space, and remove unwanted block definition entities faster while keeping a controlled undo workflow. command: | Main Commands and Loading Method 🧰 Load the LISP file with APPLOAD or with (load "DeleteObjectFromBlock.lsp"). Run ExtractFromBlock to open the shared extraction dialog and pick nested block objects. Run DeleteObjectFromBlock to open the same dialog and remove nested block objects from a selected block definition. The target platform is AutoCAD and AutoCAD based vertical products using AutoLISP, Visual LISP COM, DCL dialogs, nested entity selection, and ActiveX database editing. description: | Detailed Description 📘 This AutoLISP program provides a compact block cleanup workflow for AutoCAD users who need to extract or remove individual nested objects from inside a block reference without opening the Block Editor manually. The user starts ExtractFromBlock or DeleteObjectFromBlock, chooses whether to retain objects by copying them to model space, and then picks nested geometry inside block references with nentselp. When Retain objects is enabled, the selected nested object is copied into model space, transformed with the nested selection matrix, assigned to a cleaned local layer name, and then deleted from the source block definition. When Retain objects is disabled, the selected nested object is deleted only from the block definition without creating a model space copy. This tool is useful for AutoCAD block cleanup, nested object extraction, block definition editing, symbol repair, DWG maintenance, drawing simplification, and CAD production cleanup. Important: the program edits the source block definition, so all block references that use the same definition may change after the selected nested object is removed. helper_function: | Helper Logic 🧩 Shared DCL dialog builder - EFB:WriteDCL writes a temporary DCL file for the extraction and delete options. 🧰 Dialog control workflow - EFB:ShowDialog loads the generated dialog, sets Retain objects on by default, and returns the selected mode. 🔍 Nested entity picker - EFB:PickLoop uses nentselp so the user can pick objects inside a block reference. 🔒 Block safety checks - the pick loop rejects attributes, xrefs, layout blocks, non-nested picks, and invalid nested block paths. 📐 Matrix-based extraction - EFB:ProcessEntity recreates the selected object with entmakex and transforms it with vla-transformby. 🏷️ Layer cleanup logic - the code strips xref-style layer prefixes, creates a local layer when needed, and copies color, linetype, and lineweight settings. 🧹 Source object removal - after extraction or delete-only processing, the original nested object is removed with vla-Delete. 🔄 Undo grouping and regeneration - vla-StartUndoMark, vla-EndUndoMark, and vla-Regen group and refresh the operation. functionalities: | Functionalities 🚀 Extract nested block objects - copies a picked object from inside a block into model space and removes it from the block definition. 🔴 Delete nested block objects - removes unwanted internal block geometry without creating a copy in model space. 🧠 Shared command workflow - ExtractFromBlock and DeleteObjectFromBlock use the same dialog and pick loop. 📌 Retain objects toggle - lets the user choose between copy and remove or delete only before picking nested geometry. 🔍 Interactive pick loop - repeatedly asks the user to pick nested objects and ends when the user presses Enter. 📐 Accurate object placement - applies the nested transformation matrix so extracted geometry is placed correctly in model space. 🏷️ Layer preservation and cleanup - keeps extracted objects on a clean local layer and can copy color, linetype, and lineweight settings. 🔒 Xref and layout protection - avoids editing xref blocks and layout definitions. 🧹 Block definition cleanup - removes unnecessary internal objects from reusable blocks to reduce DWG clutter. 🧰 Temporary DCL interface - generates and deletes the DCL file automatically from the Windows TEMP folder. 🔄 Undo-aware editing - wraps the pick session in an AutoCAD undo mark for easier rollback. result: | Final Result ✅ The final result is a practical AutoCAD block editing and cleanup tool that lets users extract useful nested geometry from block definitions or delete unwanted internal objects with fewer manual steps. It improves DWG cleanup, block maintenance, CAD production speed, and drawing quality control by combining a simple DCL interface with direct nested entity selection and automated block definition editing. additional_info: | Additional Info and Limitations 🔴 Destructive behavior: removing a nested object edits the block definition, so every reference of that block definition may be affected. 🔒 Attribute limitation: the program rejects ATTRIB objects and does not extract block attributes. 📌 Selection limitation: the user must pick a nested object inside a valid non-xref and non-layout block reference. 🧩 Copy limitation: extraction uses entmakex, so unsupported entity data may fail and will be skipped. 🧰 Configuration note: the DCL file is generated dynamically in the Windows TEMP folder and deleted after the dialog closes.