In AutoCAD Civil 3D, by using expressions, we can set up separate mathematical formulas using the existing properties. Expressions are unique to a particular label style type. Only those properties that are relevant to the label style type are available in the Expressions dialog box.
After you set up expressions, they are available in the Properties list in the Text Component Editor so that you can add them to label styles. In effect, expressions become new properties that you can use to compose a label style.
Now if you want to access the expression formula / string used for a particular Label style using API, its simple, you need to get the ExpressionCollection for that Label Styles collection.
Here is a C# .NET code snippet demonstrating how to access an expression formula used for AlignmentLabelStyles :
using (Transaction trans = db.TransactionManager.StartTransaction())
{
// Get the desired Lable Styles collection
LabelStyleCollection lblStyleColl = civilDoc.Styles.LabelStyles.AlignmentLabelStyles.GeometryPointLabelStyles;
// Now get the Expression collection
// Expressions are unique to a particular label style type.
ExpressionCollection expColl = lblStyleColl.Expressions;
try
{
foreach (Expression lblExp in expColl)
{
ed.WriteMessage("\n Expression Name : " + lblExp.Name);
ed.WriteMessage("\n Expression String : " + lblExp.ExpressionString);
}
trans.Commit();
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
ed.WriteMessage("\n Exception message :" + ex.Message);
}
}