BIM

Making a DWG lighter: three commands and numbers from a real drawing

Making a DWG lighter takes three built-in commands. Measured on a real structural plan: 13 layers, 18 blocks, 9 text styles and 109 surplus lines gone.

  • TS. Đỗ Quốc Hoàng
  • 8 min read
Definition table counts before and after cleaning a real structural drawing Photo: Diagram by the Institute of Information Technology in Civil Engineering

The file opens slowly, panning stutters, and sending it takes forever. Making a DWG lighter usually gets answered with folklore, while AutoCAD has three built-in commands that do exactly that job.

This article runs all three on a structural plan in production use at the Institute and measures every number. For standardising documents properly, see the AutoCAD for Construction course.

A drawing is heavy for two separate reasons

Before cleaning, know what you are cleaning. A DWG carries weight in two quite different groups.

The first is geometry: lines, text, dimensions, hatching. This is the part you can see.

The second is the definition tables: layers, blocks, text styles, dimension styles, linetypes. Unused definitions of this kind never appear on screen, sit quietly in the file, and are usually where the bloat lives after a drawing has been copied from job to job.

Each of the three commands attacks a different place.

CommandWhat it removes
PURGEdefinitions nothing uses any more
OVERKILLduplicate lines and overlapping segments
AUDITstructural faults inside the file

How many unused definitions PURGE actually removes

The alias is PU. Autodesk's PURGE page describes it in one line: "Removes unused items, such as block definitions and layers, from the drawing." We ran the command-line version, -PURGE, set to clear everything without asking, and counted the definition tables again.

Before and after cleaning Photo: Definition table counts before and after running -PURGE on a structural drawing in production use
Definition tableBeforeAfterRemoved
Layers301713
Blocks55353518
Text styles19109
Dimension styles624
Linetypes1055

Nearly half the layers in that drawing held no objects at all. They exist because somebody once copied a group of geometry in from another file, then deleted the geometry while the layer stayed behind.

AutoCAD reports several more lines, copied verbatim.

1 shape file deleted.

1 mlinestyle deleted.

4 groups deleted.

The lines reporting nothing to remove are worth reading too, because they show how far the command looked.

No unreferenced plotstyles found.

No unreferenced multileader styles found.

Duplicate objects are what PURGE cannot see

PURGE only removes definitions. Surplus lines lying on top of one another are invisible to it, because each of those lines is a perfectly valid object.

Duplicate objects are exactly what OVERKILL is for. We ran it immediately after PURGE on the same drawing and AutoCAD reported:

11 duplicate(s) deleted

98 overlapping object(s) or segment(s) deleted

Counting objects in model space again: from 5,237 down to 5,169, so 68 objects gone.

The 98 overlapping segments are the interesting number. Those are not exact duplicates but lines that partly lie on top of each other, which the eye never catches. They come from the habit of drawing over and trimming back, or from pasting a group of geometry back in the same place.

The command's option list is worth reading, copied verbatim from the prompt.

Enter an option to change [Done/Ignore/tOlerance/optimize Plines/combine parTial overlap/combine Endtoend/Associativity] <done>:

tOlerance is the one to treat carefully. Set it large and the command merges lines that are merely similar, editing the drawing in ways you did not intend. The default is the safe choice.

A drawing cleanup in the right order

Order matters in a drawing cleanup, because each command clears the way for the next.

  1. AUDIT first, with fixing enabled. Nothing that follows is trustworthy on a file with structural faults.
  2. OVERKILL next, to remove duplicates and overlaps.
  3. PURGE after that, because deleting geometry can leave further definitions unused.
  4. PURGE again. Nested blocks usually take two passes.
  5. Save with SAVEAS over the same file. An ordinary save appends changes; SAVEAS rewrites the whole file.

That last step is the one people skip and the one that drops the file size most visibly. Saving and downgrading files is covered in our article on saving to an older version, and cleaning up the surplus layers this article counted is covered in our article on layers.

What making a DWG lighter is worth in practice

Two questions decide whether the effort pays: how often, and on which files.

On a file you work in daily, once a week is plenty. The definitions accumulate slowly, and the geometry you add deliberately is not what bloats it.

On a file arriving from outside, run the whole sequence before doing anything else. A drawing that has been through three offices carries all three offices' layer schemes, text styles and block libraries. The counts in this article came from exactly such a file.

There is one case where making a DWG lighter matters more than convenience: files to be attached as external references. A heavy reference file is loaded by every drawing that attaches it, so its weight is multiplied across the set. Cleaning the reference once saves time on every sheet that uses it.

And one case where it is worth skipping: an archived file already issued to a client. Cleaning changes the file, and a file that has been issued should stay exactly as issued.

Blocks that will not purge, and how to find them

Some blocks survive PURGE however many times you run it. Autodesk's help carries a whole topic on finding them, so this is not a rare situation.

Three causes, most common first.

First, the block is in use somewhere you cannot see. A block on a layer that is switched off, or in a layout you never open, still counts as in use.

Second, the block is nested inside another. Block A is unused, but block B sits inside A. The first pass removes A and only then does B become removable. This is exactly why two passes are needed.

Third, a special object is holding it. A dimension style, a leader style or a table can all point at a block as an arrowhead or a marker symbol.

The quickest way to track one down is to list the blocks and compare that list against what survives the clean. Anything still present after two passes is being held by something, and the three causes above cover nearly every case. For any block you cannot place, use an object filter on the block name to find where it sits.

What these three cannot fix

If all three run and the file is still heavy, the weight is somewhere else. Four common places.

Attached images. A site photograph attached to a drawing can outweigh all the geometry several times over. Check in the external references palette.

Dense hatching. A hatch with a small spacing over a large area generates an enormous number of lines. Increasing the spacing lightens it at once.

Polylines with too many vertices. Curves digitised from a scan often carry thousands of vertices for one smooth arc. A vertex-reduction command recovers a great deal.

Application data left behind. Files that have passed through structural or infrastructure software carry that software's own data. Recent PURGE versions include an option for unused application data, though it does not always clear everything.

Does cleaning lose anything?

The question everybody worries about. The measurement above answers it fairly clearly: the object count in model space fell by only 9 after PURGE, while definition counts fell by dozens.

Those nine were empty groups. No geometry was touched at all, because PURGE by definition removes only what nothing uses.

OVERKILL is different and deserves care. It deletes real geometry, surplus though it may be. Copy the file before running it on anything important.

Three things often repeated that are not true

Often repeatedWhat we measured on the 2027 release
One PURGE clears everythingNested blocks take two passes; the drawing measured kept giving on the second
PURGE deletes drawing geometryThe object count fell by 9, and those were empty groups
A heavy drawing means too much geometryThe drawing measured had 30 layers of which 13 were empty; the invisible part is the bloat

Frequently asked questions

What does the PU alias do?

It runs PURGE, the command that removes definitions no object refers to any more.

Which command should I run first?

AUDIT to fix structure, then OVERKILL, then PURGE twice, then save with SAVEAS.

Will PURGE lose part of my drawing?

No. On the drawing we measured the geometry count barely moved; what went were empty definitions and empty groups.

The file is still heavy after all three. Why?

Check four places: attached images, dense hatching, polylines with too many vertices, and data left behind by other software.

How often should I clean a working drawing?

Once a week is plenty on a file you work in daily. Files arriving from outside deserve the whole sequence before you touch anything, because they carry every previous office's layers, styles and block library.

Is OVERKILL safe?

It deletes real geometry, so copy the file first. Leave the tolerance at its default, because a large value merges lines that are merely similar.

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