You can use “BlockTableRecord” API “IncludingErased” to get the block table record with erased entities. Once you have erased entities, you can unease the entities if required as shown in below code.
[CommandMethod("GetErasedEntities")]
public void GetErasedEntities()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
ObjectId ModelSpaceId =
SymbolUtilityServices.GetBlockModelSpaceId(db);
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTableRecord record = tr.GetObject(ModelSpaceId,
OpenMode.ForRead) as BlockTableRecord;
BlockTableRecord withErasedBTR = record.IncludingErased;
foreach (ObjectId Id in withErasedBTR)
{
if (!Id.IsErased)
continue;
//un erase the entity...
//GetObject, 3rd parameter openErased
Entity ent = (Entity)tr.GetObject(Id,
OpenMode.ForWrite, true);
ent.Erase(false);
}
tr.Commit();
}
}

Leave a Reply