AutoCAD Civil 3D Tip: It's All in the Expression

By:  Bryan Sullivan

Our corridor is designed and we’re ready to cut cross sections. We have a Code Set Style assigned to generate the labels we wish to display, but we have a problem. The labels in the left ditch appear as desired, but the labels in the right ditch are overlapping and hard to read.

Code Set Style Civil 3D

We certainly don’t want to edit dozens (or hundreds!) of cross section labels manually. We could make a global edit to our Code Set Style or Label Styles, but that would change the entire section. We like the left side the way it is. Can we just change the right side without changing the left? If Civil 3D only allows one Label Style to be assigned to each Link Code, is it even possible to display the same Link Labels in a different way on each side?

One way of approaching this problem is by using Expressions.

Civil 3D Expressions are mathematical expressions that can be used in place of static values in Label Styles. We will use Expressions to modify the data in the standard label style components. Expressions are stored in the Settings tab of the Toolspace, within the Label Style folders. In this example, we will be using Expressions to control the size of our label text for the specific condition of controlling their display in the right ditch of our section.

Currently, our Link Label Styles consists of a text component with a static value for Text Height. We are going to replace that value with an expression.

Toolspace Settings Tab Civil 3D

To create our Expression we’ll navigate the Settings tab of the Toolspace.

General > Label Styles > Link > Expressions

Right-click on “Expressions” and select “New…”

Active Drawings Setting View Civil 3D

The New Expression dialog box will appear.

New Expression Dialog Box Civil 3D

Our first expression we create will control the text height of the Slope Ratio label on our sideslopes. Since our right ditch labels are overlapping because of the smaller size of the ditch, we will use the size value of the slope link to determine the size of our label text.

1 The expression we will use is: IF({Link Length}<2.5,.05/12,.06/12)

Which means: If the length of the sideslope link is less than 2.5 feet, then the value of the text height should be .05 inches (divide by 12 is added to convert feet to inches), if it is not less than 2.5 feet then the value of the text height should be .06 inches.

We’ll name this expression “Sideslope Text” and click “OK” to create our expression.

Now we need to add our new expression to our Label Style.

If we open our Label Style Composer for our Slope Ratio label and click on the Text Height value, we will now see our expression available in a drop down menu. We’ll set our Text Height value to the new “Sideslope Text” expression and click “OK” to finish.

Label Style Composer for Slope Ratio Civil 3D

(We can create a similar expression for the Slope Percent label on the flat bottom of our ditch and apply it in the same manner.)

Now if we take a look at our sections, we’ll find that the text in the right ditch has automatically resized and is no longer overlapping.

Cross Section Labels Civil 3D

This sure beats having to edit dozens (or hundreds!) of cross section labels manually. Next time we’re faced with a similar problem, just remember, it’s all in the expression.

1 In this example, we used the Link Length property and the IF function to create our expression. Other properties and functions available for an expression can be found using the two buttons on the right side of the dialog.

Link Length property and IF Function Civil 3D

 

Last Month’s Tips:

dialog to import linestyle library                Roadway Designer Place Temporary Dimension2                      Changecolor Sub

MicroStation Tip:  Import Linestyles      InRoads Tip:  Place Dimensions                VBA Tip:  Maximize the
into a DGN Library                                    in Roadway Designer                            MicroStation ElementEnumerator

 

Don’t want to miss out on other great information? Subscribe to this blog or our monthly eNewsletter now!
Learn More ◊ Contact us today ◊ Newsletter ◊
EnvisionCAD Group EnvisionCAD YouTube Channel   

 

EnvisionCAD

Since 1996, EnvisionCAD has been a nationally recognized leader in the configuration, customization, implementation, training & support for CAD software solutions. Our individualized approach has benefited private engineering firms and government agencies alike. Basic or advanced, we can help you get the most from your CAD technology.

Tags: ,

6 comments on “AutoCAD Civil 3D Tip: It's All in the Expression

  1. Kirk Reply

    Great trick with the expression. I have been working with just this type of setup for sometime, but have always dealt with a dragged leader justification issue when the dragged state display component is set to as composed. Have you or any of your client come across a solution?

  2. Owen Reply

    Can expressions produce strings (i.e. text)?

    e.g. if the area of a parcel is less than or equal to 10,000sq-ft
    then expression equals “A”

  3. Bryan Sullivan Reply

    Hi Owen,

    Right now expressions can only return values. There is not a way to store text strings. Text strings are asked for by many, perhaps if we are lucky in a future release.

    This may not be exactly what you are looking for, but if you want the output to display or not display based on the value, you can create an expression that sets the text height to 0 when a certain condition is or met.

    IF({Parcel Area}>10000,0,.06/12)

    If the parcel area is greater than 10,000 then the text height is 0 (invisible). If the area is less than or equal to 10,000 then the text height is .06 (visible).

  4. Jwan Reply

    Hello everyone :

    How I can make one expression in order to gate sag and cover for the pipe line on the profile , I means if the angle its more zero its should be cover and more less zero its should be sag.

    Thanks for all

Leave a Reply

Your email address will not be published. Required fields are marked *