Wednesday, January 2, 2013

Labeling Contours at Given Intervals

I was recently asked by a client what was the best method for quickly labeling contours intermittently.  By intermittently,  I mean labeling every other contour, or every third contour.   The client explained that they go through this process by using the contour single command and manual picking every two or three contours, depending on the interval required.  After giving this process some thought,  I figured there had to be a much more efficient way of doing this using an expression.  As most of you know, Civil 3D allows us to create a mathematical expression from other data residing within the software.  In the case of the random intervals, I can create an expression that will see if the contour is at the appropriate interval, and display it. If it is not, then it will be hidden.  In the screen capture below, here is the expression I have created.


Here is the expression:  IF({Surface Elevation}/2=TRUNC({Surface Elevation})/2), {Surface Elevation}, -1)

The expression starts of with the IF command, which tells the expression to check for given output.  The surface elevation/2 is telling the interval at which we want our contours to be displayed.  In this example, we want to label every other contour, but this could  be set to /3, which would check for every third contour, etc.  By using the TRUNC command, we are checking to see if the contour is divide by 2 evenly.  For example, a surface elevation of 102 would generate a value of 51 and a truncated value of 51, where as a surface elevation of 101 would generate a value of 50.5 and a truncated value of 50.  In the example, the surface elevation 102 would be labeled, while 101 would not.  This portion is taken care of by the last part of the expression which is {Surface Elevation}, -1.  If the statement is true, then it uses the surface elevation, if not it generates a -1 value for a false statement.    


The reason we are having the statement generate a negative value is that the label style composer, as seen above, the Sign option allows us to hide negative values.  Note, in my expression, I'm having a false statement generate a value of -1, but in theory, it could be any number as long as it is negative.  This is ultimately how we can have Civil 3D label contours at a given interval.  



Here is what your new label should look like.  Why spend anymore time then needed to quickly label your contours.

No comments:

Post a Comment