public void Union(Dictionary <string, ObjectId[]> dicDeleteDimStyles, DimStyleTableRecord[] resultStyleName) { using (Transaction t = targetDB.TransactionManager.StartTransaction()) { DimStyleTable tblStyle = (DimStyleTable)t.GetObject(targetDB.DimStyleTableId, OpenMode.ForWrite); foreach (var _style in dicDeleteDimStyles) { foreach (var _x in _style.Value) { DBObject item = t.GetObject(_x, OpenMode.ForWrite); Dimension y = (Dimension)item; if (y.Annotative != AnnotativeStates.True) { SetStyleAnnotative(resultStyleName, item, y); } SetStyleByType(resultStyleName, item, y); } if (!CanBeRemoved(_style.Key)) { continue; } List <DimStyleTableRecord> dimStyles = tblStyle.Cast <ObjectId>().Select(n => (DimStyleTableRecord)t.GetObject(n, OpenMode.ForWrite, true)).ToList(); DimStyleTableRecord styleDel = dimStyles.Select(x => x).Where(x => x.Name.ToUpper().Equals(_style.Key)).ToList()[0]; styleDel.Erase(); } t.Commit(); } }
private List <DimStyleTableRecord> GetDimStyles(Database db) { List <DimStyleTableRecord> alldimStyles = new List <DimStyleTableRecord>(); List <DimStyleTableRecord> dimStyles = new List <DimStyleTableRecord>(); using (Transaction tr = db.TransactionManager.StartTransaction()) { DimStyleTable tblStyle = (DimStyleTable)tr.GetObject(db.DimStyleTableId, OpenMode.ForRead); alldimStyles = tblStyle.Cast <ObjectId>().Select(n => (DimStyleTableRecord)tr.GetObject(n, OpenMode.ForRead)).ToList(); } foreach (DimStyleTableRecord item in alldimStyles) { if (item.Name.Contains('|')) { continue; } dimStyles.Add(item); } return(dimStyles); }