Database.Purge API can be used to identify the un-used registered applications. Once un used registered application names are identified, use “erase” API to remove the registered application names from the drawing file.
[CommandMethod("PurgeApplicationName")]
public static void PurgeApplicationName()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
using (Transaction Tx =
db.TransactionManager.StartTransaction())
{
RegAppTable table = Tx.GetObject(db.RegAppTableId,
OpenMode.ForRead) as RegAppTable;
ObjectIdCollection regIds = new ObjectIdCollection();
foreach (ObjectId id in table)
{
regIds.Add(id);
}
//this function will remove all
//app names which are used in the drawing file
db.Purge(regIds);
foreach (ObjectId id in regIds)
{
DBObject obj = Tx.GetObject(id, OpenMode.ForWrite);
obj.Erase();
}
Tx.Commit();
}
}

Leave a Reply to Stephen PrestonCancel reply