Monday, October 17, 2011

AutoCAD: PURGE, AUDIT, RECOVER, Repeat...

I know I said I wasn't going to write any more AutoCAD-related articles, but this was sparked by a recent client visit, so I felt it was worth revisiting.  I've mentioned the AutoCAD PURGE command before, but it needs to be revisited.

Something that is very unique to the world of CAD is the extent to which content is reused.  More than any other class of application:  word processing, spreadsheets, databases, desktop publishing, even more than photographic and illustration applications.  CAD shops around the world routinely insert library content from years of accumulated work.  Everything from the smallest items to sheet borders, to complex 3D components and entire compound assemblies.  Content is king, and CAD content is the king of kings.

But there's a problem.  Along with the visual attributes there is an entire world of non-visual baggage that comes along with every reused chunk of content.  Layers, dimension styles, text styles, linetypes, shapes, extended data (xdata) and xrecords, are just a typical brush stroke of examples of things that often sneak in with each library part insertion.

But wait: There's more!

Along with the legacy visual, and sinister non-visual stuff, there's the often overlooked issue of inconsistent and inaccurate data structures.  I'm talking about the DWG format itself.  With each release of AutoCAD, for example (I'm sure this is applicable to other CAD products), there are improvements to the methods and processes for detecting errors in the data format and correcting them.  Some of the tools in AutoCAD that help with this are AUDIT and RECOVER.  There's also WBLOCK and DXFOUT, and other methods/tricks, but you get the idea.  The problem is that rarely do CAD managers or anyone else take the time to comb back through years of old DWG files to run these tools and clean them up.

Most often what happens is we get into a habit of inserting content, exploding it, erasing what we don't need, then running PURGE and saving.  At least run AUDIT when you do that.  If you don't, you risk corrupting the new drawing, or at the very least you'll bloat it to death.  File size is not something to ignore.  The bigger the file, the slower it copies and the slower it gets backed up.  It also takes longer to open and longer to save, especially across a network connection.

AUDIT (fix errors)
PURGE (nested)
PURGE (nested) again
AUDIT (fix errors) again
SAVEAS (new dwg file) replace the old dwg file

I haven't bothered to search, but I'm sure there are at least a few products available for helping to batch process drawing files for you.  Even if you can't afford to purchase one, you could build something using LISP, VSA, ObjectARX, VBscript, Javascript, KiXtart, PowerShell, or just two sticks and a bucket of mud.  Whatever the case, don't ignore this.  Just because you ran AUDIT and PURGE on those old drawings back when you used AutoCAD R14 or 2000, doesn't mean they can't still contain errors and junk that AutoCAD 2012 would find and correct.

8 comments:

Anonymous said...

Thanks for writing about Autocad once again.

Did you use Object DBX a lot and if yes was it a reliable way to modify DWG files without autocad.

joshc96 said...

One should consider that, if the DWG file is old enough, hatches and heavey polylines could be updated to save more space. The old hatch method produced an actual block containing entities representing the pattern whereas the new method saves the pattern and boundary internally and the hatch is generated upon opening the drawing. LWpolylines require less info per entity than heavy polylines.

-Josh

BTW, I read your blog daily but most of the IT stuff (which is the job that was dropped into my lap at the office) is way over my head so there's not much for me to comment on...but it's interesting nonetheless.

skatterbrainz said...

When you say "without AutoCAD" I assume you mean that AutoCAD is installed, but not by launching it to perform the automated batch processing. I have worked with ObjectDBX quite a bit, but not in regards to running PURGE or AUDIT. It's really aimed at mining the DWG structure and content than running commands, but it's been a while since I've done *any* AutoCAD programming (no money in that profession, so I moved into mainstream IT).

skatterbrainz said...

Thanks @joshc96! I appreciate that very much! That's true about polylines and hatch entities. Thanks for sharing that.

Jason said...

David,

Hope you and your family are well!

May I suggest a way to do this. I have recently been using the Action Recorder in AutoCAD 2012. With the Recorder you basically record your commands as they happen. So I recorded a macro with the following:

- Audit
- Purge
- Qsave

With the purge command its best to use the command line version i.e. -purge Using this will enable the user to purge all the items or specify individual groups to purge. The best thing about the Action recorder is that the name you give to the recorded actions lets you call it up from the command line. So for noobs like myself who quite don't know how to program in AutoCAD, this is a great solution.

Jason

skatterbrainz said...

Excellent! Thanks for sharing with everyone!

Anonymous said...

Be sure to purge "Regapps" which can only be accessed via the command line or with the Regapp Cleanup tool from the autodesk website.

-purge
regapps
*
n

I've encountered DWG files with 2 million regapps making the files large and performance suffer.

Anonymous said...

Supposedly, RECOVER does a more thorough job of auditing a drawing than AUDIT does.