.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Purging
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
338 Views, 2 Replies
01-19-2010 03:56 AM
Need a bit of help with purging materials from a drawing. I have managed to purge all items within a named object table like layers and blocks but those in the Named Object dictionary table are confusing me a little.
Do I need to itterate through the named objects dictionarys to get the AEC_MATERIAL_DEFS dictionary then purge the contents from there?
Thanks for any help.
Daniel
Do I need to itterate through the named objects dictionarys to get the AEC_MATERIAL_DEFS dictionary then purge the contents from there?
Thanks for any help.
Daniel
Re: Purging
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-19-2010 04:27 AM in reply to:
dheselwood
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
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
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
Gilles Chanteau
Re: Purging
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-19-2010 04:33 AM in reply to:
dheselwood
I see, you can directly access the materialdictionaryID - I thought it would need itterating through each named dictionary to find the materials dictionary.
Thanks Gile.
Thanks Gile.
