.NET

Reply
Member
hatak
Posts: 5
Registered: ‎04-18-2006
Message 1 of 1 (107 Views)

How to erase objects from active layer C#

107 Views, 0 Replies
05-09-2006 02:53 PM
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 :smileywink:

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