Purge

  • In the last post we introduced a static C# class containing extension methods for the ObjectId and Transaction classes. The new Transaction methods allow you to more easily "lock" objects, whether because they're "system" objects you want to keep around in every drawing or because they're objects that shouldn't be purged at whim by users. Under the hood, the implementation uses Xrecords stored in the Named Objects Dictionary that contain hard-pointer references to the various locked objects. This stops the PURGE command from removing them, but also allows us to check via Database.Purge() – or our new ObjectId.IsErasable() shortcut –…

  • This is one of those topics that has been at the back of my mind for a number of years. Here's a question I received via a blog comment back in 2009: I was wondering if there's an easy way to modify the objects to purge. For example, if a particular text style was included in the drawing that I did not want to be purged. Can this easily be done? Here's how I responded, at the time: There are a couple of ways: You can maintain your own list of objects "to keep" and remove any items that are…

  • In the last post we looked at some code to programmatically purge Registered Application names from the drawing currently active in AutoCAD. In this post we take the "batching" code first used in this previous post and apply it to this problem. What we end up with is an additional command called PF which asks the user to specify a folder and then purges the RegApps from the DWGs in that folder, saving those files that end up being modified with the "_purged" suffix. One point to note is the use of the Database.RetainOriginalThumbnailBitmap property: as we're not making any…

  • Purging can seriously reduce the size of AutoCAD drawings by removing unnecessary symbol table and dictionary entries. The PURGE command in AutoCAD allows you to safely purge these non-graphical objects (layers, linetypes, block definitions, etc.). Since AutoCAD 2005 (if I recall correctly), PURGE also supports the removal of Registered Application names. Applications that make use of Extended Entity Data (XData) must register unique application names in drawings. A few applications have, in the past, created many more names than they required, and as these RegApp names get copied from drawing to drawing (when they get XRefed, for instance), they ended…