.NET

Reply

Purge Layer empty

124 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
303 Posts
1 Kudo
Registered: ‎09-26-2004
Post 2 of 3

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]

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