.NET

Reply
*GPaolo
Message 1 of 3 (115 Views)

Purge Layer empty

115 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 (115 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 (115 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]

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community