Distinguished Contributor
Posts: 196
Registered: ‎12-06-2006
Message 1 of 2 (553 Views)

Purging and Auditing files

553 Views, 1 Replies
07-12-2011 01:44 PM

I've done a few searches around the forum (and google) and found a few cryptic posts about auditing files.


I'm hoping for a straight answer to this question: Is it possible to audit a drawing with the current .Net API for AutoCAD?


If so, does it require the editor, or can it be run in the background to enable a lot of drawings to be audited very quickly.


As for purging - i've seen a few posts and articles that talk about purging a very specific thing (i.e. materials, line types, etc.).


Has anyone written a .Net utility that is similar to the Purge command in AutoCAD? By this I mean, one that will purge all unused objects in the drawing. I have started looking for all the tables that contain the IDs of all the object types that the Purge command looks for, but was also hoping that someone with more experience and time than myself had already tackled this problem.


Thanks for your time.

Distinguished Contributor
Posts: 142
Registered: ‎01-06-2003
Message 2 of 2 (421 Views)

Re: Purging and Auditing files

04-07-2012 11:47 PM in reply to: docsaintly

Here is the Purge All I use, open to comments. However I cannot find an Audit process, did you?



public static bool purgeItems(Database db, ObjectIdCollection tableIds, bool silent)
                Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
                bool itemsPurged = false;

                using(Transaction tr = db.TransactionManager.StartTransaction())
                    ObjectIdCollection purgeableIds = new ObjectIdCollection();
                    foreach(ObjectId tableId in tableIds)
                        SymbolTable table = (SymbolTable)tr.GetObject(tableId, OpenMode.ForRead, false);
                        foreach(ObjectId recordId in table)


                    if(purgeableIds.Count != 0)
                        itemsPurged = true;
                        foreach(ObjectId id in purgeableIds)
                            SymbolTableRecord record = (SymbolTableRecord)tr.GetObject(id, OpenMode.ForWrite);
                            string recordName = record.Name;
                                    ed.WriteMessage("\nPurging " +
                                        record.GetType().Name + " " + recordName);

                return itemsPurged;


Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.