LWP LISP: Delete All Entities on a Picked Layer (Free AutoLISP Download)
A layer cannot be deleted while it still contains entities, everything on it must be erased first. LWP automates that: pick one entity on the target layer, and every entity on that same layer throughout the current drawing is deleted in one step.
LYRWIPE-bgol (Delete All Entities on a Picked Layer)
Command Type: AutoLISP routine (works in AutoCAD, BricsCAD, ZWCAD and most AutoLISP-compatible CAD platforms)
Developed by: BGol Community, bgol.in
Inspired by the general concept of pick-based, layer-wide deletion utilities used in CAD drafting workflows. This is an original, independently written routine, new file name, new command name, new source code, created so the CAD community has a free, editable, open-source alternative.
Overview
A layer cannot be deleted while it still contains entities, everything on it must be erased first. LWP automates that: pick one entity on the target layer, and every entity on that same layer throughout the current drawing is deleted in one step.
How to Use
- Load
LYRWIPE-bgol.lspinto your CAD session (drag-and-drop the file onto the drawing window, or use theAPPLOADcommand). - Type
LWPat the command line and press Enter. - At the
Select entity on layer to delete:prompt, click any single entity that resides on the layer you want cleared. - The routine identifies that entity's layer and deletes every entity in the drawing on that same layer, then reports how many were removed.
Why Use It
- Enables Layer Deletion, clears all entities from a layer in one step, a necessary prerequisite before the layer itself can be deleted.
- Convenient for Scripted Regeneration, useful in workflows where a LISP program regenerates content on a specific layer; clearing the old content first avoids duplicate or stale entities.
- Simple, Pick-Based Targeting, no need to know or type the exact layer name, just click any entity on the target layer.
Where to Use It
- Clearing all entities from a layer before deleting the layer itself (native
LAYERDeleterequires an empty layer). - Regenerating drawing content on a specific layer (e.g., re-running a LISP that populates elevation text or grid lines) by first clearing prior output.
- Quickly removing an entire category of annotation or geometry organized by layer, without manually selecting every individual entity.
Notes
- Entities on a locked layer cannot be erased by AutoLISP; the routine will report how many entities were skipped for that reason, if any.
- This routine only deletes entities, it does not delete the layer definition itself. Use the native
LAYER/-LAYERDeleteoption afterward if you also want the now-empty layer removed. - Source code is fully open, feel free to study, modify, and redistribute it under the same open, free-for-all spirit.
Credits
Developed and shared for the CAD community by BGol Community. Website: https://bgol.in/ Free and open-source, use it, modify it, share it, for personal or commercial work alike.
Frequently Asked Questions
LWP is a standard AutoLISP routine, so it runs in AutoCAD, BricsCAD, ZWCAD, and most other AutoLISP-compatible CAD platforms without modification.
Entities on a locked layer cannot be erased by AutoLISP; the routine will report how many entities were skipped for that reason, if any.
Enables Layer Deletion, clears all entities from a layer in one step, a necessary prerequisite before the layer itself can be deleted.
Yes. LWP is fully open-source and free to use, modify, and redistribute for both personal and commercial work, developed and shared by the BGol Community.
Drag and drop LYRWIPE-bgol.lsp onto your open drawing window, or load it through the APPLOAD command, then type LWP at the command line to run it.
🤝 About BGol Community
BGol Community of Advanced Surveying builds and shares free, open-source tools for the survey and CAD drafting community.
🙌 Made with ❤️ by BGol Community of Advanced Surveying
Free, open-source, and built for the CAD community, for personal or commercial use, always.