Monday, July 26, 2010

What does the AutoCAD "PURGE" Command Do?

I've explained this to users for almost 15 years.  I'm a bit tired of it, so I'm going to say it "here" one more time and then that's it.  No more.  After that I'm just going to point inquisitors to this site and tell them to "enjoy!"

AutoCAD drawings are structured in a quasi-database hierarchy. Among the many types of things inside a drawing file (.DWG file) there are entities, such as LINE, ARC, CIRCLE, ELLIPSE and TEXT entities.  Another thing is "tables", which are essentially logical groups of things like LAYERS, DIMSTYLES, text STYLES, BLOCK definitions, and so on.

Entities refer to tables for things like what Layer they're on, what color and linetype they have (if not "by layer"), linetype scale, dimension style, text style (which in turn dictates the font, weight, size and so on), and that sort of stuff.

As things are created or inserted into a drawing, they bring along the relevant table information (if it's not already present in the current drawing).  So if you insert a DWG as a BLOCK INSERT which includes entities on layer "FUBAR" which is blue, but the current drawing doesnt' have that layer, then that layer is also imported.  If that layer already exists, but the color is green, the entities in the block insertion on layer "FUBAR" will be green.

So when you delete entities from your drawing, the table entries do not go away automatically.  They remain.  Using the preceding example, if you wanted the entities on layer "FUBAR" to insert and bring along their original layer properties, you would first need to clear out layer "FUBAR" from your current drawing.  If entities in your drawing are using that layer, well, you can't clear out the layer.  But if NOTHING refers to that layer, then you can remove it using the PURGE command.

Sometimes you have to purge multiple times to remove nested table references.  By that I mean when you have a block insertion that contains a block insertion with another block insertion inside that.  You get the idea.  You explode the first block, but that leaves another block with a nested block.  If you explode all of them (or programmatically reach into them and change their nested properties), and reset all of their entities to some other layer, and nothing refers to "FUBAR" anymore, then "FUBAR" can be purged.

There.  Clear as mud.  Drink up and enjoy!

5 comments:

Anonymous said...

cheers mate!

The CAD Setter Out said...

Great article Dave.

I have included a link to your excellent post from my Blog:
Skatterbrainz and the AutoCAD purge command

skatterbrainz said...

Thank you!

Unknown said...

Would I be able to reproduce this on my own blog, with a back link to yourself. I am always asked this question also and you explain it way better than I could.

skatterbrainz said...

Why reproduce it? When you can always post a summary with a back link.