Hi,
This will purge all non referenced materials
{code}ObjectIdCollection ids = new ObjectIdCollection();
using (Transaction tr = db.TransactionManager.StartTransaction())
{
DBDictionary matDict = (DBDictionary)tr.GetObject(db.MaterialDictionaryId, OpenMode.ForRead, false);
foreach (DBDictionaryEntry entry in matDict)
{
string key = entry.Key;
if ((key != "ByBlock") && (key != "ByLayer") && (key != "Global"))
ids.Add(entry.Value);
}
db.Purge(ids);
foreach (ObjectId id in ids)
{
DBObject obj = (DBObject)tr.GetObject(id, OpenMode.ForWrite);
obj.Erase();
}
tr.Commit();
}{code}
Edited by: _gile on Jan 19, 2010 1:28 PM