.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to erase objects from active layer C#

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
238 Views, 0 Replies

How to erase objects from active layer C#

I wrote code like this:

Database db = HostApplicationServices.WorkingDatabase;
Transaction trans = db.TransactionManager.StartTransaction();
try
{
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
ObjectIdCollection ids = new ObjectIdCollection();
foreach (ObjectId id in bt)
{
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
ids.Add(btr.ObjectId);
}
db.Purge(ids);
if (ids.Count > 0)
{
foreach (ObjectId id in ids)
{
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
btr.Erase(true);
}
}
trans.Commit();
}
catch
{

}

finally
{
this.Show();
trans.Dispose();
}
but it's not working
I don't know if it is right way do do this, simillar code works fine to erase layers. If anyone has any sugestions I woud be grateful.

Thanks for your time 😉
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost