AutoCAD – Drawings

Deleting a layer in AutoCAD: five reasons it refuses

Deleting a layer in AutoCAD fails for five reasons. Eight kinds of layer tested on AutoCAD 2027, and locking or switching one off blocks nothing at all.

  • TS. Đỗ Quốc Hoàng
  • 8 min read
Eight kinds of layer put to the test: three delete, five are refused with the same message Photo: Diagram by the Institute of Information Technology in Civil Engineering

A drawing arrives with 180 layers and perhaps twenty of them in use. Select a spare one, press delete, and nothing happens. Press it again, still nothing. Deleting a layer in AutoCAD turns out not to be a matter of pressing a button.

This article builds a drawing holding eight different kinds of layer on AutoCAD 2027, tries to delete each one, and records exactly which go and which stay. For the whole discipline of organising a drawing, the Institute runs an AutoCAD course for construction.

Three ways to delete, and they do different jobs

Before pressing anything it pays to know how these three differ, because picking the wrong one either deletes nothing or takes a piece of the drawing with it.

RouteDeletes whatHow safe
The Delete Layer button in the layer paletteOnly an empty layerSafest; a layer holding objects is refused
The PURGE command, aliased PUEvery layer nothing references, in one passSafe; it only removes what nobody points at
The LAYDEL commandThe objects and the layerDangerous; a piece of the drawing goes

In other words, deleting a layer in AutoCAD is not one action but three, and they differ in whether geometry is lost. The first two never lose a line. The third does, and that is precisely what it is for.

A layer that will not delete: five reasons, measured

Rather than describe this in general terms, here is a drawing built with eight kinds of layer, each one then put to the test.

Kind of layerStateResult
IIC-TRONGempty, referenced by nothingdeleted
IIC-KHOAlocked, holds no objectsdeleted
IIC-TATswitched off, holds no objectsdeleted
0a system layerrefused
Defpointscreated automatically by dimensionsrefused
IIC-TUONGholds objectsrefused
IIC-HIEN-HANHis the current layerrefused
IIC-TRONG-BLOCKused only inside a block definitionrefused

All five refusals come back with exactly one sentence, whatever the underlying reason.

Object is referenced by other object(s)
Eight kinds of layer put to the test Photo: Eight kinds of layer put to the test: three delete, five are refused with the same message

The first three rows are the interesting ones. A locked layer deletes. A layer that is switched off deletes. The two most common pieces of advice — unlock it first, turn it back on first — are both unnecessary. The only thing that decides the outcome is whether anything still references the layer.

Which raises the obvious question: if the message never varies, how do you tell the five cases apart? By elimination, and in a fixed order. Check whether the layer is current, because that is a one-click fix. Then check whether anything sits on it, by making it the only visible layer. What survives both checks is either a system layer or something hidden inside a block or an xref.

The five refusals, and what to do about each:

ReasonWhat to do
Layer 0 and DefpointsCannot be deleted and should not be; leave them
Objects still sit on the layerMove them to another layer, or use LAYDEL
It is the current layerMake a different layer current, then try again
Used only inside a block definitionDelete or edit that block definition first
It belongs to an external referenceDetach the xref and the layer goes with it

The fourth row is the nastiest trap. The layer looks empty on the drawing and the palette says nothing, yet inside a block definition there is geometry sitting on it. Either explode a block to find out, or simply accept that it stays. Managing blocks is covered in our article on blocks in AutoCAD.

The purge command clears unused layers in one pass

When a hundred need clearing rather than one, the right command is PURGE, aliased PU. The command-line version is -PURGE, which is what to write into a script.

Measured on the drawing above, which at that point held 7 layers, two of them spare.

RunLayers beforeLayers afterRemoved
First752 layers
Second550 layers

The second run removed nothing, exactly as it should: the command clears only what nothing references, and after the first run no such layer was left.

Worth noting is what it did not remove: the layer used only inside a block, despite that layer looking empty. That is evidence it examines real references rather than appearances. For clearing unused layers it is the safest route available, because it cannot lose geometry. Slimming a drawing down is covered in our article on lightening a CAD drawing.

The laydel command takes the objects too

This is the command for a layer that holds geometry you also want gone. Autodesk describes it on the LAYDEL page in one line: "Deletes all objects on a layer and purges the layer."

The prompts, copied verbatim from the 2027 release.

Command: LAYDEL
Select object on layer to delete or [Name]:
Selected layers: IIC-TUONG.
Select object on layer to delete or [Name/Undo]:
******** WARNING ********
You are about to delete layer "IIC-TUONG" from this drawing.
Do you wish to continue? [Yes No] <No>:

Two details there are worth remembering. First, the command prints an actual WARNING line and names the layer about to disappear. Second, the default is <No>, so pressing Enter to hurry through does nothing at all — a careful piece of design.

What was measured after answering Yes:

MeasuredBeforeAfter
Objects in model space32
Layers54

The line went, the layer went. Exactly Autodesk's one sentence, no more and no less. Reach for it only when you are certain that part of the drawing is not needed.

The order to work in

Put together, this sequence works on any drawing. Go from safe to dangerous, never the other way.

StepWhat to doWhy it sits here
1Run PU, choose Layers, Purge AllClears everything unreferenced, no risk
2Make a different layer currentRemoves the easiest refusal to fix
3Run PU againThe old current layer can now go
4Look at what is left, one at a timeOnly now is inspection worth the effort
5Use LAYDEL on what you are sure aboutThe only step that loses geometry

Step three is the one people skip. A single PURGE is rarely enough, because clearing one layer can leave another with nothing pointing at it. Run it until it reports zero and the drawing is genuinely clean.

Layers that arrive from somewhere else

A drawing from another firm usually brings hundreds of unfamiliar layers. Two groups among them resist the ordinary route.

Layers belonging to an external reference. Their names carry a |, as in XREF-A|TUONG. They belong to the referenced file rather than this drawing, so deleting them directly does not work. Detach the xref and they go with it. Managing references is covered in our article on xrefs in AutoCAD.

Layers used inside blocks. As measured above, such a layer looks empty and is still refused. If the drawing carries blocks nobody uses any more, purge the blocks first and a second layer purge will clear a good many more.

One practical closing thought: do not try to clear every last one. Spare layers add almost nothing to the file size and change nothing about the plotted sheet. Tidying the list enough to read it is sufficient; leave the stubborn ones alone.

Four things often repeated that are not true

Often repeatedWhat was measured on the 2027 release
A layer must be unlocked before it can be deletedA locked but empty layer deleted normally
A layer must be switched on before it can be deletedA switched-off but empty layer deleted normally
A layer that looks empty can certainly be deletedOne used only inside a block was refused
One run of PURGE clears everythingThe first run cleared 2; run it until it reports 0

Frequently asked questions

I press the delete button and the layer stays. Why?

Because Delete Layer only removes an empty layer. One holding objects, one that is current, and 0 and Defpoints are all refused.

How do I clear a hundred spare layers at once?

Type PU, choose Layers, then Purge All. Run it a few times until it reports that nothing more can be cleared.

The layer looks empty and still will not delete.

It is most likely used inside a block definition, or it belongs to an external reference. Neither shows any geometry on the drawing itself.

How do I remove the objects along with the layer?

Use LAYDEL. Remember it erases every object on that layer, and that the default answer to its final question is No.

I deleted the wrong layer — can I get it back?

Type U to undo immediately; LAYDEL undoes like any other command. Once the drawing has been saved and closed, only a backup file will help.

Why does Defpoints keep coming back?

Because the software recreates it the moment a dimension is placed. It holds the definition points of every dimension, which is also why it never plots.

Should I try to get rid of 0 and Defpoints?

No. Both are system layers, the software always refuses, and every drawing has them.

About the author

TS. Đỗ Quốc Hoàng — Vice Director of the Institute of Information Technology in Civil Engineering, Hanoi University of Civil Engineering, and a specialist in software development for construction