Friday, October 15, 2010

Civil 3D 2-digit Spot Elevation Labels Done Right

Until today I have been using a spot elevation label method that returns 4.56 instead of 04.56 for the elevation 1204.56. See my earlier post on Abbreviated (short) elevations in AutoCAD Civil 3D 2009.

I just tested successfully a new idea for showing two-digit elevations (04.56 instead of 1204.56 or 4.56) (2014 update: I have corrected it to also show 1204.9999 as 05.00 instead of 04.00):

1. Under Toolspace, Settings, Surface, Label Styles, Spot Elevation, Expressions add an expression named "Surface Elevation hundreds" ROUND({Surface Elevation}*100)/10000

2. Under Toolspace, Settings, Surface, Label Styles, Spot Elevation, <your style>, Edit, Layout tab, enter this where you want the two-digit elevation:


This is the code that needs to end up in the right pane of the Label Text Component Editor:

<[Surface Elevation hundreds(P2|RT|AP|GC|UN|Sn|ORD)]><[Surface Elevation(Uft|P2|RN|AP|GC|UN|Sn|ODS)]><[Surface Elevation(Uft|P2|RN|AP|GC|UN|Sn|ORD)]>

In human language, the above adds the elevation in three pieces. For the elevation 1204.56, it adds 1) the "04" from 12.04, 2) the "." from 1204.56, and the "56" from 1204.56.

Explanation for elevation 1204.5588:
CodeResultExplanation
<[Surface Elevation hundreds(P2|RT|AP|GC|UN|Sn|ORD)]>04ROUND(1204.5588*100)/10000 = 12.0456. Truncate it to two decimal places => 12.04. Output what's right of the decimal => 04.
<[Surface Elevation(Uft|P2|RN|AP|GC|UN|Sn|ODS)]>.Output the decimal sign from the surface elevation => "." (in American English)
<[Surface Elevation(Uft|P2|RN|AP|GC|UN|Sn|ORD)]>56Output the part of Surface Elevation right of the decimal => 56

Explanation for elevation 1204.9999:
CodeResultExplanation
<[Surface Elevation hundreds(P2|RT|AP|GC|UN|Sn|ORD)]>05ROUND(1204.9999*100)/10000 = 12.05. Truncate it to two decimal places => 12.05. Output what's right of the decimal => 04.
<[Surface Elevation(Uft|P2|RN|AP|GC|UN|Sn|ODS)]>.Output the decimal sign from the surface elevation => "." (in American English)
<[Surface Elevation(Uft|P2|RN|AP|GC|UN|Sn|ORD)]>00Round the Surface Elevation normally and output the part right of the decimal => 00

I would LOVE to do Civil 3D consulting work for any of you at any time.

9 comments:

Craig said...

I'm having a problem when you add 0.5' to the Pavement or Gutter elevation. How do i incorporate Gutter +0.50' = TC and then {surface elevation} /100?

Thomas Gail Haws said...

What I do is create two expressions for each offset elevation label I need. Like this:

A. EXPRESSIONS
1. Surface Elevation
a) Surface Elevation: the original Civil 3D surface elevation
b) Surface Elevation hundreds: {Surface Elevation}/100

2. Up 0.67
a) 0.67 up: {Surface Elevation} + 0.67
b) 0.67 up hundreds: {0.67 up}/100

B. LABEL TEXT
1. On surface: <[Surface Elevation hundreds(P2|RN|AP|GC|UN|Sn|ORD)]><[Surface Elevation(Uft|P2|RN|AP|GC|UN|Sn|ODS)]><[Surface Elevation(Uft|P2|RN|AP|GC|UN|Sn|ORD)]>

0.67 up
<[0.67 up hundreds(P2|RN|AP|GC|UN|Sn|ORD)]><[0.67 up(Uft|P2|RN|AP|GC|UN|Sn|ODS)]><[0.67 up(Uft|P2|RN|AP|GC|UN|Sn|ORD)]>

Anonymous said...

I tried the Surface Elevation you showed. It worked, but not when it is 1212.9995 is the original elevation.
I tried Truncate, and it didn't show 13.00. I tried round normal, and all of my elevation turned to 13.XX instead of 12.XX on all elevation 1212.5X and above.

Thomas Gail Haws said...

Thank you very much for the alert. I have revised step 1. Please let me know how it works for you.

Anonymous said...

Thank you for the great post!

Anonymous said...

Hi
I try to display Point Elevation 1234.56 to 34.56 but not work for me.
Please help me
Thanks

Thomas Gail Haws said...

Where are you stuck? What can you do?

Anonymous said...

Thanks
I add all point to drawing C3D 2015 , I will to Display label of Elevation Point 2 decimal of left point for Exp:1023.65 to 23.65
your example foe surface not work for point

Thomas Gail Haws said...

You should be able to use the same general approach for Point labels. But you will need to access the Point label styles differently than you access the Spot Elevation label styles. I believe you will need to (want to) manage Point styles through Point Group Styles. You will be happiest in the long run doing that.