Tuesday, February 22, 2011

Civil 3D Label Styles-Using Expressions

For every project we use either the out of the box styles or create new styles to meet the specific requirements of the company we work for or the project we are working on

Once they are included in our template we have everything covered, right?

But what if you need to display a property of an object that isn’t available under the Label Style Composer? Or maybe we want to display the label in a different way based on a certain value of the object?

Over the next few posts we are going to dig into the use and application of Label Expressions that can be applied in a variety of simple and complex labeling situations.

First, let’s take a quick look at the fundamentals of the Expressions.

Expressions are located under the Settings tab of the Toolspace, under the Label Styles folder.







The New Component dialogue box consists of a number of components that are used to create the Expression

1. In the Name field enter a relevant, identifiable name for your Expression

2. The Expression field will contain all the formulas and properties as the Expression is developed.

3. Buttons that may be used to aid in the development of the Expression (you can enter by the keyboard if you prefer)

4. The available object properties that may be inserted in the Expression field.

5. Functions that may be used in the development of the Expression

6. Chose how the results of the Expression are to be formatted. Usually always Double. (Unitless)



As an example let’s create an Expression that will truncate a pipe length label to the nearest 0.50 metre.

We get this request at times because not everyone wants the accuracy of a pipe length shown to the tenth of a metre.

To create the Expression right click on the “Expressions” and select New







As an example let’s create an Expression that will truncate the pipe length label to the nearest 0.50 metre.

1. In the dialogue box enter a name and description for the Expression that reflects the resultant label style.

2. Pick the Formula button to expand the Expression Functions, in our case select the ROUND function








This inserts the ROUND function to the Expression window.


Next we need to add the Object Property by picking the Object the Properties button and picking the appropriate Property.


In our case we will select 2D Length-Center to Center which is automatically inserted into the Expression window.







Now we just need to add a little more math to complete the Expression and then click OK.






The new Expression will be displayed in the Previewwindow of the Toolspace>Settings tab under the Pipe Label Styles and is now available to be applied to a pipe label







To add the Expression to the Label Style create a New pipe Label by copying and editing an existing style.







Copy the default Length Description and Slope label style and rename it Rounded Length and Slope







Select the Layout tab and in the Text section on the Contents row pick the corresponding cell in the Value column and pick the Ellipse button to access the Text Component Editor







In the preview window of the Component editor highlight the “2D Length…” string and press delete to remove it from the label




In the Properties section pick the down arrow and locate the “Pipe Length to Nearest 0.5m” Expression that was created, set the Precision to 0.1 and click the UPDATE arrow to update the label in the preview window

Click OK twice to closer the Component Editor and Label Composer.




Apply the new pipe label to the pipe object and the center to center length with be rounded to the nearest 0.50m

Pipe Label



Actual Pipe Properties







Now that we have the basics down our next post will address a few more complicated Expressions and their applications.

cheers

dh