Function Syntax: DeleteLayerByFilter / LayDelByList
Version: 1 Date: 17.08.2025
Version: 2 Date: 20.06.2026 6:38:52PM
N/A
Important details and safeguards
• The dialog hides xref dependent layers and reserved layers 0 and Defpoints.
• Deletion is driven by Express Tools -LAYDEL which removes all objects on those layers similar to the native workflow.
• If Express Tools is not present the code attempts a normal API delete which only succeeds for empty layers.
• The command does not rename layers and does not move objects elsewhere. It deletes contents on the selected layers as part of the layer removal process.
Why this is helpful
• Speeds up cleaning drawings by batching multiple layer deletions with a safe discoverable UI.
• Reduces repetitive command line input while keeping the exact same confirmation logic as manual -LAYDEL.
UI elements at a glance
• Filter edit box that accepts text or wildcards.
• Matching layers list box with multi select support.
• Buttons: Clear Filter then Select All then Select None then Delete then Cancel.
Commands provided
• DeleteLayerByFilter — opens the dialog and deletes layers selected in the UI.
• LayDelByList — deletes all layers listed in the variable LAYLIST.
Requirements and notes
• Requires Express Tools for full functionality because -LAYDEL is part of Express Tools.
• Works in localized environments by trying underscored and plain command options for -LAYDEL.
• Use with care. Deleting layers via -LAYDEL is destructive and cannot be undone once the undo chain is broken. Consider saving a backup before use.
Typical workflow
Type DeleteLayerByFilter.
Type a filter such as A-* then select desired layers then click Delete.
Read the command line summary to confirm how many layers were deleted and which failed if any.
List mode example
(setq LAYLIST '("V-GENL-SURV-ANNO" "V-TOPO-BREAKLINE" "V-BSS-SURV-PT" "V-CTRL-SURV-PT"))
(LayDelByList)
Description
🧹 DeleteLayerByFilter is an AutoCAD and Civil 3D AutoLISP utility for filtering, exporting, and deleting drawing layers through a controlled DCL dialog.
🛡️ The routine focuses on safer layer cleanup by combining wildcard filters, protected layer patterns, preset filters, export reports, and confirmation prompts before destructive operations.
Function Syntax
🚀 Main command: DeleteLayerByFilter
🧰 List-based command: LayDelByList
SEO Optimized Overview
🔎 This AutoCAD layer filter and layer delete tool scans all layers in the active drawing and displays matching names in a multi-select DCL list.
🧩 The dialog contains five filter boxes combined by OR logic, making it useful for Civil 3D layer cleanup, consultant DWG cleanup, xref background cleanup, and CAD standard correction.
🔁 The Inverse filter option shows layers that do not match the filters, helping users find unexpected or non-standard layer names.
🛡️ Protected patterns prevent accidental deletion of key layers such as 0, DEFPOINTS, xref layers, annotation layers, dimension layers, Civil 3D surface layers, point layers, alignments, profiles, corridors, pipe networks, structures, parcels, and viewports.
📤 The tool can export selected, displayed, or all matching layer names to a TXT file before deleting anything.
Primary Workflow
1️⃣ Run DeleteLayerByFilter in the AutoCAD command line.
2️⃣ Enter one or more layer filters or use a preset such as Civil_3D_Layers, Architecture, Survey, or Structural.
3️⃣ Click Apply Filters to rebuild the matching layer list.
4️⃣ Review the results, select specific layers, or export the list to TXT for checking.
5️⃣ Use Delete Selected or Delete All Matching only after confirming that the matched layers are correct.
Functionalities
✅ Five layer filter boxes - filter drawing layers by multiple wildcard-compatible names.
✅ OR filter logic - show layers matching any of the active filters.
✅ Inverse matching - show layers not matching the current filter set.
✅ Preset layer filters - quick buttons for Civil 3D, Architecture, Survey, and Structural workflows.
✅ Preset save and load - stores reusable filter configurations as .dlbf files.
✅ Layer list export - exports selected, displayed, or all matching layer names to TXT.
✅ Protected layer system - skips default, xref, annotation, dimension, viewport, and Civil 3D object layers.
✅ Delete fallback logic - tries -LAYDEL first and then uses ActiveX layer deletion as a fallback.
✅ Capacity protection - limits DCL list size to avoid oversized dialog lists in drawings with many layers.
Key Commands and Helper Functions
🚀 C:DeleteLayerByFilter - opens the layer cleanup dialog.
🧰 C:LayDelByList - deletes layers from a predefined LAYLIST variable while respecting protected patterns.
🧩 DLBF-FilterLayersOR - applies the active filter pattern list to all layer names.
🧩 DLBF-IsProtectedLayer - checks if a layer must be skipped for safety.
🧩 DLBF-WriteLayerListToFile - exports layer audit results to a TXT file.
🧩 DLBF-LayDel - deletes layers through the AutoCAD -LAYDEL command.
🧩 DLBF-VLA-Delete - attempts deletion through the ActiveX Layers collection.
Practical Result
🎯 The final result is a controlled AutoCAD layer cleanup workflow that helps CAD users remove unwanted layers while preserving essential Civil 3D, xref, annotation, and viewport layers.
📌 DeleteLayerByFilter is useful for consultant DWG cleanup, imported drawing cleanup, survey background cleanup, architecture or structural xref cleanup, and production drawing standardization.
Important Notes
⚠️ This tool can delete layers from the active drawing; save or back up the DWG before testing broad filters.
⚠️ Broad wildcards can match many layers because all five filters are combined by OR logic.
⚠️ Protected layers are skipped, but layers in use, locked layers, current layers, or layers controlled by xrefs may still fail to delete.
⚠️ Export the matching layer list first when cleaning important project drawings.
Tags
🏷️ AutoCAD, 🏷️ Civil 3D, 🏷️ AutoLISP, 🏷️ Visual LISP, 🏷️ Layer cleanup, 🏷️ Delete layers, 🏷️ Layer filter, 🏷️ LAYDEL, 🏷️ DCL dialog, 🏷️ Layer manager, 🏷️ CAD standards, 🏷️ Protected layers, 🏷️ Xref layers, 🏷️ Layer export, 🏷️ Filter presets, 🏷️ Drawing cleanup, 🏷️ CAD automation, 🏷️ Production drawings
Function Syntax: DeleteLayerByFilter
Version: 1 Date: 17.08.2025
N/A
Important details and safeguards
• The dialog hides xref dependent layers and reserved layers 0 and Defpoints.
• Deletion is driven by Express Tools -LAYDEL which removes all objects on those layers similar to the native workflow.
• If Express Tools is not present the code attempts a normal API delete which only succeeds for empty layers.
• The command does not rename layers and does not move objects elsewhere. It deletes contents on the selected layers as part of the layer removal process.
Why this is helpful
• Speeds up cleaning drawings by batching multiple layer deletions with a safe discoverable UI.
• Reduces repetitive command line input while keeping the exact same confirmation logic as manual -LAYDEL.
UI elements at a glance
• Filter edit box that accepts text or wildcards.
• Matching layers list box with multi select support.
• Buttons: Clear Filter then Select All then Select None then Delete then Cancel.
Commands provided
• DeleteLayerByFilter — opens the dialog and deletes layers selected in the UI.
• LayDelByList — deletes all layers listed in the variable LAYLIST.
Requirements and notes
• Requires Express Tools for full functionality because -LAYDEL is part of Express Tools.
• Works in localized environments by trying underscored and plain command options for -LAYDEL.
• Use with care. Deleting layers via -LAYDEL is destructive and cannot be undone once the undo chain is broken. Consider saving a backup before use.
Typical workflow
Type DeleteLayerByFilter.
Type a filter such as A-* then select desired layers then click Delete.
Read the command line summary to confirm how many layers were deleted and which failed if any.
List mode example
(setq LAYLIST '("V-GENL-SURV-ANNO" "V-TOPO-BREAKLINE" "V-BSS-SURV-PT" "V-CTRL-SURV-PT"))
(LayDelByList)