Express Yourself: Using Expressions in Civil 3D


Expressions in Civil 3D have been around since the beginning of time……Civil 3D time!  However, I don’t think people utilize expressions to their full capabilities, or even at all.  I’ve heard of some pretty cool ways people are using expressions to label and analyze their models in Civil 3D and thought I’d share a few.

This article helps walk through setting up a couple expressions, starting with simple mathematical formulas to more advanced analysis expressions.

About Expressions

Expressions are stored in the Settings tree, within the label style type folders. They are not available for label style types that do not have relevant properties, such as Note label styles.  But for the most part, they are available in every type of label such as surface, alignment, profile, etc.

You insert expressions into label styles using the Text Component Editor when you are editing a label style text component.

Insert expressions in Civil 3D from Autodesk

Expressions make use of the same properties that you can add to label styles, such as Point Elevation, Northing, and Easting. By using expressions, you can set up separate mathematical formulas using the existing properties. There are two main portions to creating an expression.  You will find these in the New Expression dialog box.

Insert Property

Inserts a property into the expression. Click the icon to display a list of properties relevant to the expression type. Select a property to insert it into the expression. These are the same properties that are available for label styles.

Properties are inserted inside brackets. Do not add operators or functions within these brackets.

Insert Function

Inserts a function into the expression. Such as IF(test,true_val,false_val), ROUNDUP(x,y), etc

For example, you could subtract a value from a point elevation, and display that number alongside the actual elevation in a point label.  Let’s create that example.


Creating a Simple Expression

For this first expression, we will keep it very simple.  In this example, we will create a label for a parking lot, using a spot elevation we will label the LIP of gutter, but within the same label, have it label the TBC (Top Back of Curb) with an elevation difference of 0.33’ (or 0.17’ for shed curb).  Let’s get started:

1.       Go to your SETTING tab, expand surface, label styles and Spot Elevation.
2.       Right click on Expressions and select NEW

Creating simple expressions in Civil 3D from Autodesk


3.       Name your expression “Capture Curb - LIP / TBC”.
4.       Give your expression a description.  I like using descriptions here so that end users, other than the expression creator, can understand the intention of the expression.
5.       At the bottom of the New expression dialog box, change the Format result as to ELEVATION
6.       In the Expression Editor box, select SURFACE ELEVATION from the INSERT PROPERTY drop down.
7.        After you insert that property, type in (or select from the dialog box) +0.33. 
8.       Select OK to accept and save your expression.

Creating a new expression in Civil 3D from Autodesk


9.       Let’s now add this to a Spot Elevation label style, and label our surface.  Create a new Spot Elevation style called “Elev Label - Capture Curb + LIP”
10.    In the label style, we will have two text components, one for our main surface spot we wish to label (LIP) and the other that will reference our expression (TBC)
11.    In the Text Component Editor Properties, you will now see your expression, add that to the new component.
12.    Properly compose your label as shown in FIG05.

Text component editor in Civil 3D from Autodesk




13.    Now use the ADD LABELS dialog box to add the newly created label to a few spots.  You can now see that by labeling the one spot, the mathematical equation we setup in the expression will then add the 0.33’ we specified.

Adding labels in Civil 3D from Autodesk


Now let’s try some more advanced expressions!

Expression for Cut / Fill Text

Another useful example for expressions is to use them to aid in labeling cut vs. fill labels in a volume surface.  For example, you may want to display your CUT in red, and you FILL in blue.  To do so, we will setup a couple quick expressions.

1.       First, ensure you have a VOLUME surface created.  This goes without explain, but thought I would mention it anyway!
2.       Create two expressions, one for the Cut Text height and one for the Fill Text height.
3.       Name this first expression Cut-Text. Use this as the expression:
a.       IF({Surface Elevation}<0,0.10/12,0.00000001)
4.       Name this second expression Fill-Text. Use this as the expression:
a.       IF({Surface Elevation}<=0,0.12/12,0.00000001)

What we are doing here, is creating a super small text that will NOT show up once we place our labels.  These expressions are slightly different, we won’t use these in our label composer, but we will use these to adjust the text height and differentiate Cut v. Fill.

5.       Create a label style that has 2 components, Cut and Fill text.  These components reference the Surface Elevation, but in the text height property, you will set the corresponding expression (Cut/Fill).
6.       Change the CUT component color to RED.
7.       Change the FILL component to BLUE.

Label Style Composer in Civil 3D in Autodesk


8.       Test this out by using your new label style to label a surface!!

Use label style to labe a surface in Civil 3D!


Expression for Pipe Calculations

Want to have dynamic flow rates or velocities for your gravity networks?  One way to do so is to create an expression utilizing the Manning’s equation to get the flow rate (Q) and the flow velocity (V)

The expression for Q for feet drawings is:

1.486*pi*((({Start Crown Elevation}-{Start Invert Elevation})/2)^2)*(1/{Manning Coefficient})*((({Start Crown Elevation}-{Start Invert Elevation})/4)^(2/3))*(SQRT({Pipe Slope}))

Once we have completed the expression for Q, we can create the expression for V (or other calcs):

Q/(pi*({Inner Pipe Diameter}/2)^2)

Time in Pipe could be another necessary calculation:

{2D Length - To Inside Edges}/Velocity/60

Misc. Expressions

Here are a few others I’ve used in Civil 3D.

Truncate your elevations.  An example of this is displaying an elevation of 132.67 as 32.67:
·         {Surface Elevation}-100*TRUNC({Surface Elevation}/100)

2 Point Slope Arrow – Arrow always pointing downhill
·         IF({Surface Slope} <= 0, 0, pi)
·         This expression gets applied to the Rotation Angle of the direction arrow component.

Truncate your elevations in Civil 3D expressions from Autodesk


Pipe True Slope
·         ({Start Invert Elevation}-{End Invert Elevation})/{2D Length - To Inside Edges}

Length in Meter – Display both (any object)
·         {Segment Length} *.3084

Slope Distance AND Horizontal Distance in a label (Use on lines, polylines, figures and feature lines)
·         SQRT({General Segment Length}^2-(ABS({General Segment Start Z}-{General Segment End Z})^2))

Conclusion

There are many…MANY expressions you can create within Civil 3D. Hopefully this helps get the brain going and thinking about how you can further increase your productivity by testing the limits of label styles and expression composition.

As always, I am interested to hear what you think and see how we can improve upon this topic.  If you have some crazy cool expressions, I’d love to see them in action, shoot me an email or connect with me on LinkedIn.

Good luck and EXPRESS YOURSELF!!

- Shawn Herring

Comments