public static AlignmentLabelSet ByName(Autodesk.AutoCAD.DynamoNodes.Document document, string labelStyleName) { AlignmentLabelSet retLabel; Database db = document.AcDocument.Database; LabelSetStylesRoot root = CivilDocument.GetCivilDocument(db).Styles.LabelSetStyles; AlignmentLabelSetStyleCollection alignRoot = root.AlignmentLabelSetStyles; using (Transaction trans = db.TransactionManager.StartTransaction()) { retLabel = new AlignmentLabelSet(trans.GetObject(alignRoot[labelStyleName], OpenMode.ForRead), false); trans.Commit(); } return(retLabel); }
public static List <CivilDynamoTools.LabelStyles.Alignments.AlignmentLabelSet> GetAlignmentLabelSets(Autodesk.AutoCAD.DynamoNodes.Document document) { List <CivilDynamoTools.LabelStyles.Alignments.AlignmentLabelSet> alignmentLabels = new List <CivilDynamoTools.LabelStyles.Alignments.AlignmentLabelSet>(); Database db = document.AcDocument.Database; LabelSetStylesRoot root = CivilDocument.GetCivilDocument(db).Styles.LabelSetStyles; AlignmentLabelSetStyleCollection alignRoot = root.AlignmentLabelSetStyles; foreach (ObjectId setStyle in alignRoot) { using (Transaction trans = db.TransactionManager.StartTransaction()) { AlignmentLabelSet labelSet = new AlignmentLabelSet(trans.GetObject(setStyle, OpenMode.ForRead), false); alignmentLabels.Add(labelSet); trans.Commit(); } } return(alignmentLabels); }