Back

Express Yourself: Using Expressions in Civil 3D

Expressions in AutoCAD® 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 Styles folders (see Figure 1). 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, and so on.

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

Figure 1

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, which you will find 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 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:

  • Go to your SETTING tab, expand surface, label styles, and Spot Elevation.
  • Right-click on Expressions and select NEW (Figure 2).

Figure 2

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

Figure 3

  • 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”.
  • In the label style, we will have two text components, one for the main surface spot we wish to label (LIP) and the other that will reference our expression (TBC).
  • In the Text Component Editor Properties, you will now see your expression; add that to the new component (Figure 4).
  • Properly compose your label as shown in Figure 5.

Figure 4

Figure 5

  • 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 set up in the expression will then add the 0.33’ we specified (Figure 6).

Figure 6

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 versus fill labels in a volume surface.  For example, you may want to display your CUT in red, and your FILL in blue.  To do so, we will set up a couple quick expressions.

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

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

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

Figure 7

Test this out by using your new label style to label a surface (Figure 8).

Figure 8

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

Miscellaneous 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)

Two-Point Slope Arrow—arrow always pointing downhill (Figure 9):

  • IF({Surface Slope} <= 0, 0, pi)
  • This expression gets applied to the Rotation Angle of the direction arrow component.

Figure 9

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 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!!

Appears in these Categories

Back