.NET

Reply
*GPaolo
Message 1 of 3 (113 Views)

Purge Layer empty

113 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
Posts: 303
Registered: ‎09-26-2004
Message 2 of 3 (113 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 (113 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
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

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

Ask the Community