.NET

Reply
*GPaolo
Message 1 of 3 (121 Views)

Purge Layer empty

121 Views, 2 Replies
04-28-2006 02:46 AM
I need to Purge the layer not used that dont contain nothing.
There is a flag that contain this information.
Or i must ,before erase the layer, make a selection with filter for each
layer?

to Purge block i have found :
ObjectIDs = Blocco.GetBlockReferenceIds(True, True)

this function return a collection of objectid that is the number of
blockreference still insert.

Many thank's in advance.

GPaolo
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 2 of 3 (121 Views)

Re: Purge Layer empty

04-28-2006 05:34 AM in reply to: *GPaolo
[code]
[CommandMethod("PurgeAllNonRefLayers")]
static public void PurgeAllNonRefLayers()
{
Database db = HostApplicationServices.WorkingDatabase;
Transaction trans = db.TransactionManager.StartTransaction();
try
{
LayerTable lt = (LayerTable)(trans.GetObject(db.LayerTableId, OpenMode.ForRead));
ObjectIdCollection ids = new ObjectIdCollection();
foreach (ObjectId id in lt)
{
LayerTableRecord ltr = (LayerTableRecord)(trans.GetObject(id, OpenMode.ForRead));
ids.Add(ltr.ObjectId);
}
db.Purge(ids);
if (ids.Count > 0) {
foreach (ObjectId id in ids) {
LayerTableRecord ltr = (LayerTableRecord)(trans.GetObject(id, OpenMode.ForWrite));
ltr.Erase();
}
}
trans.Commit();
}
finally
{
trans.Dispose();
}
}
[/code]
*GPaolo
Message 3 of 3 (121 Views)

Re: Purge Layer empty

04-28-2006 06:27 AM in reply to: *GPaolo
Perfect.
Many Thanks
GPaolo
ha scritto nel messaggio
news:5157787@discussion.autodesk.com...
[code]
[CommandMethod("PurgeAllNonRefLayers")]
static public void PurgeAllNonRefLayers()
{
Database db = HostApplicationServices.WorkingDatabase;
Transaction trans = db.TransactionManager.StartTransaction();
try
{
LayerTable lt = (LayerTable)(trans.GetObject(db.LayerTableId,
OpenMode.ForRead));
ObjectIdCollection ids = new ObjectIdCollection();
foreach (ObjectId id in lt)
{
LayerTableRecord ltr = (LayerTableRecord)(trans.GetObject(id,
OpenMode.ForRead));
ids.Add(ltr.ObjectId);
}
db.Purge(ids);
if (ids.Count > 0) {
foreach (ObjectId id in ids) {
LayerTableRecord ltr = (LayerTableRecord)(trans.GetObject(id,
OpenMode.ForWrite));
ltr.Erase();
}
}
trans.Commit();
}
finally
{
trans.Dispose();
}
}
[/code]
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.