public void DeleteReddit() { string layerName = ""; Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; using (Transaction tr = db.TransactionManager.StartTransaction()) { LayerTable layerTable; layerTable = tr.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable; foreach (string layername in LayerNameList.GetLayerNames()) { //Select entities from layer names ObjectIdCollection objects = DrawEntity.SelectByLayer(layername); foreach (ObjectId obj in objects) { var ent = tr.GetObject(obj, OpenMode.ForWrite); ent.Erase(true); } //Now delete the layer LayerTableRecord layerTableRec = tr.GetObject(layerTable[layername], OpenMode.ForWrite) as LayerTableRecord; layerTableRec.Erase(true); } tr.Commit(); } }
public void ThawReddit() { string layerName = ""; Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; using (Transaction tr = db.TransactionManager.StartTransaction()) { LayerTable layerTable; layerTable = tr.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable; foreach (string layername in LayerNameList.GetLayerNames()) { if (layerTable.Has(layername)) { LayerTableRecord layerTableRec = tr.GetObject(layerTable[layername], OpenMode.ForWrite) as LayerTableRecord; layerTableRec.IsFrozen = false; } } tr.Commit(); } }