Skip to content

Instantly share code, notes, and snippets.

@Civil3DToolChest
Created March 12, 2014 15:22
Show Gist options
  • Save Civil3DToolChest/9509114 to your computer and use it in GitHub Desktop.
Save Civil3DToolChest/9509114 to your computer and use it in GitHub Desktop.
get general label style by name
public ObjectId getGeneralLabelStyle(string name)
{
ObjectId lblId = ObjectId.Null;
Document acadDoc = Application.DocumentManager.MdiActiveDocument;
CivilDocument civilDoc = CivilApplication.ActiveDocument;
Boolean hasStyle = civilDoc.Styles.LabelStyles.GeneralNoteLabelStyles.Contains(name);
if (hasStyle)
{
using (Transaction trans = acadDoc.Database.TransactionManager.StartOpenCloseTransaction())
{
foreach (ObjectId id in civilDoc.Styles.LabelStyles.GeneralNoteLabelStyles)
{
LabelStyle lblstyle = trans.GetObject(id, OpenMode.ForRead) as LabelStyle;
if (lblstyle.Name == name)
{
lblId = id;
}
}
trans.Commit();
}
}
return lblId;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment