Short description
- DeleteLayerByFilter — embedded DCL layer deleter with filter + multi-select, using -LAYDEL scripted sequence with VLA fallback
- v10 change: fixes the -LAYDEL command sequence to mirror manual steps: ._-LAYDEL → _N → <name> → "" → _Y (plus localized fallback)
- Excludes Xref layers and reserved layers (0, DEFPOINTS) and reports deleted vs failed

Command:
- • DeleteLayerByFilter
- • LayDelByList
Description:
- Provides a single-file LISP with an embedded DCL dialog titled Delete Layers by Filter to find and delete multiple layers at once.
- Builds a list of candidate layers from the drawing, excluding Xref-dependent layers (names matching *|*) and excluding reserved layers 0 and DEFPOINTS.
- Supports filtering by wildcard (*, ?) or by plain text (auto-wrapped as *text*), and allows multi-select in the list box.
- Deletes selected layers primarily through Express Tools -LAYDEL using a scripted command sequence; if unavailable or unsuccessful, falls back to attempting a VLA delete as a last resort.
- Includes an additional command that deletes layers from a user-defined list variable LAYLIST using the same deletion pipeline and reporting.
Helper function: (if any)
- • DLBF-TempDclPath — generates a temp path for the dialog DCL file.
- • DLBF-WriteDcl — writes the embedded DCL string to disk and returns the path for load_dialog.
- • DLBF-GetAllLayers — enumerates drawing layers, excludes Xrefs (*|*) and reserved (0, DEFPOINTS), returns sorted list.
- • DLBF-Patternize — converts plain text into wildcard pattern (*text*) unless the user already supplied wildcard characters.
- • DLBF-FilterLayers — filters layer names by wcmatch against the pattern; empty pattern returns all candidates.
- • DLBF-Split — splits a string into tokens by delimiter character code (used to parse selection index strings).
- • DLBF-ParseIndexList — parses the list_box multi-select index string into a list of integers (space-delimited).
- • DLBF-IdxRangeStr — builds an index string "0 1 2 …" for Select All without relying on vl-number-sequence.
- • DLBF-LayDel — deletes a layer by name using ._-LAYDEL with sequence _N name "" _Y; retries with non-underscore N/Y fallback; verifies deletion by checking tblsearch.
- • DLBF-VLA-Delete — last-resort attempt to delete a layer via VLA (only succeeds when deletion is allowed).
- • DLBF-DeleteLayers — orchestrates deletion across names, blocks reserved/xref layers, counts successes, accumulates failures with reason tags.
Functionalities:
- • Embedded DCL UI — dialog includes filter edit box, multi-select list of matches, and buttons: Clear Filter, Select All, Select None, Delete, Cancel.
- • Layer candidate set — enumerates layers and excludes Xref-dependent names (*|*) and reserved layers (0, DEFPOINTS).
- • Filtering rules — empty filter shows all; wildcard filters are honored as-is; plain text is converted to *text* for “contains” matching.
- • Live list refresh — typing in the filter edit box updates the match list immediately by repopulating lb_layers.
- • Select All / None — Select All sets list_box selection to the full index range string; Select None clears the selection tile string.
- • Index parsing — on Delete, reads list_box selection indices, parses them into integers, and maps indices back to layer names.
- • Primary deletion path — attempts layer removal via -LAYDEL scripted input sequence and validates success by confirming the layer no longer exists in the table.
- • Fallback deletion path — if scripted deletion fails, attempts VLA deletion of the layer object as a last resort (typically only works if layer is deletable/empty).
- • Reporting — prints how many layers were deleted and lists failed layer names (including (reserved) and (xref) annotations when applicable).
- • Alternate command: LayDelByList — deletes layers from variable LAYLIST (must be a list of names) using the same checks and deletion pipeline, then prints Deleted/Failed summary.
Result:
- Running DeleteLayerByFilter opens a filterable, multi-select list of eligible layers; selected layers are deleted using the corrected -LAYDEL scripted sequence, with a VLA fallback if necessary.
- Reserved layers (0, DEFPOINTS) and Xref layers are not deleted and are reported as failures with reason tags.
- Running LayDelByList performs the same deletion logic for a predefined list variable LAYLIST and reports deleted vs failed layers in the command line output.
Images, animations etc.




Log in
