upgradePntLabelStyle(string nameLabelStyle, string nameFontFile = "Romans.shx", double xscale = 0.8) { LabelStyle ls = null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { LabelStyleCollection labelStyles = BaseObjs._civDoc.Styles.LabelStyles.PointLabelStyles.LabelStyles; if (labelStyles.Contains(nameLabelStyle)) { labelStyles.Remove(nameLabelStyle); } //Layer.manageLayers(name); TextStyleTableRecord TStr = Txt.getTextStyleTableRecord("L100"); if (TStr == null) { TStr = Txt.addTextStyleTableRecord("L100"); } TStr.FileName = nameFontFile; TStr.XScale = xscale; CivilDocument civDoc = BaseObjs._civDoc; ObjectId id = civDoc.Styles.LabelStyles.PointLabelStyles.LabelStyles.Add(nameLabelStyle); ls = (LabelStyle)tr.GetObject(id, OpenMode.ForWrite); ls.Properties.DraggedStateComponents.DisplayType.Value = Autodesk.Civil.LabelContentDisplayType.StackedText; addLocationZcomponent(ls); addPointNumberComponent(ls); addDescriptionComponent(ls); tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Pnt_Style.cs: line: 254", ex.Message)); } return(ls.ObjectId); }
checkPntLabelStyles() { try { using (Transaction tr0 = BaseObjs.startTransactionDb()) { LabelStyleCollection ids = _pointLabelStyles; Dictionary <string, ObjectId> stylesWith = new Dictionary <string, ObjectId>(); Dictionary <string, ObjectId> stylesWithout = new Dictionary <string, ObjectId>(); int k = ids.Count; using (Transaction tr1 = BaseObjs.startTransactionDb()) { for (int i = 0; i < k; i++) { LabelStyle ls = (LabelStyle)tr1.GetObject(ids[i], OpenMode.ForRead); if (ls.Name.ToUpper().Contains("-LABEL")) { stylesWith.Add(ls.Name, ls.ObjectId); } else { stylesWithout.Add(ls.Name, ls.ObjectId); } } tr1.Commit(); } k = ids.Count; for (int i = k - 1; i > -1; i--) { LabelStyle ls = (LabelStyle)tr0.GetObject(ids[i], OpenMode.ForWrite); if (ls.Name.ToUpper().Contains("-LABEL")) { string name = ls.Name.Replace("-LABEL", ""); if (!stylesWithout.ContainsKey(name)) { //avoid duplicate naming ls.Name = name; } else { if (!ls.IsUsed) { ids.Remove(ls.Name); } else { ids.Remove(name); } } } if (ls.CreateBy.Contains("Autodesk")) { try { if (!ls.IsUsed) { ids.Remove(i); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Pnt_Style.cs: line: 85", ex.Message)); } } } tr0.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Pnt_Style.cs: line: 94", ex.Message)); } }