Skip to content

Instantly share code, notes, and snippets.

@Civil3DToolChest
Created March 17, 2014 19:07
Show Gist options
  • Save Civil3DToolChest/9606108 to your computer and use it in GitHub Desktop.
Save Civil3DToolChest/9606108 to your computer and use it in GitHub Desktop.
set general label style contents
public void setTextComponentContents(ObjectIdCollection componentIds, string contentString, string componentName)
{
Document acadDoc = Application.DocumentManager.MdiActiveDocument;
CivilDocument civilDoc = CivilApplication.ActiveDocument;
using (Transaction trans = acadDoc.Database.TransactionManager.StartOpenCloseTransaction())
{
foreach (ObjectId id in componentIds)
{
LabelStyleTextComponent textComponent = trans.GetObject(id, OpenMode.ForWrite) as LabelStyleTextComponent;
textComponent.Name = componentName;
textComponent.Text.Contents.Value = contentString;
}
trans.Commit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment