Hi,
I am looking for a Line Label Style Expression which will perform a rounding function on distance labels that display my "General Segment Length" value.
What I need is to be able to remove "Trailing Zeros" from my distance values, so that if precision is set to say 0.01 and my distance value is measured as 45.5, I do not get 45.50 but 45.5.
I need this to round for:
1 decimal place
2 decimal places and
3 decimal places
Can anyone assist here?
Best Regards,
Jim Williams
Solved! Go to Solution.
Solved by BrianHailey. Go to Solution.
Are you talking about one expression for all three instances? I'm not sure about that.
Otherwise, I think it is pretty simple. You need to multiply by 10, or 100, or 1000, then truncate, then divide again.
So, for three decimals:
(TRUNC(1000*{General Segment Length}))/1000
Mark Green
Working on Civil 3D in Canada
Why can't you just create a label style that sets rounding to truncate? See the attached image. I would create three general line segment styles with the following settings for my label:
General Line Segement Tenths:
Precision = 0.1
Rounding = truncate
General Line Segement Hundreths:
Precision = 0.01
Rounding = truncate
General Line Segement Thousandths:
Precision = 0.001
Rounding = truncate
Fred
-Civil 3D 2012
Hi,
Thanks for that expression, it makes basic sense, but I'm not a mathematical boffin.
I really do need to do this for the 3 cases of 2, 1 and 0 decimal places.
Any idead how I woudl form the "if" and "then" statements aroudn this for a complete solution?
Regards, Jim
I don't want to have 3 line label styles, as that so much additional work for multiple draftspeople doign this 8 hrs per day. I need 1 x label style that evaluates this and automatically does the rounding.
IF(test,valueiftrue,valueiffalse)
now, to apply that, something like....
(where g = {General Segment Length}
IF(g-TRUNCg=0,g,(IF(10g-TRUNC(10g)=0,(TRUNC10g)/10,(IF(100g-TRUNC(100g)=0,(TRUNC100g)/100,(IF(1000g-TRUNC(1000g)=0,(TRUNC1000g)/1000,g))))))
Don't know if I've got enough closing brackets at the end there. I've never tried muliple if statements inside each other, but you should get the idea. If the first test is true, return the number, if not go to the second test etc.
Mark Green
Working on Civil 3D in Canada
Your equation looks good.
How do I actually now put all this together in the contents of the "Text Components Editor"?
first of all, couple of questions.
If the length is 14.9999, how should it display?
15
15.000
14.9999
If the length is 15.0001, how should it display?
15
15.000
15.0001
Mark Green
Working on Civil 3D in Canada
Right-click, > New.
The format is important, but I'm not sure what they all mean. Distance in one option that would probably work too.
Mark Green
Working on Civil 3D in Canada
FMOD is probably a better way to go than g-TRUNCg. It messed up on me once though, didn't want to work in an alignment label referencing the profile. But it should work.
Mark Green
Working on Civil 3D in Canada
Why not just create 1 style with 3 components. Distance 1(0.0), Distance 2 (0.00) and Distance 3(0.000)? Each component can have the desired precision and rounding.
Or why not use a dimension with the option to Suppress Trailing Zeros?
Mark Green
Working on Civil 3D in Canada
Hi, and thanks for the added question here.
I have been away from my email for a week, so I apologise for the delay in responding.
I may need to describe the problem a little better.
In Australia it is a requirement to display line lengths to two or three decimal places for Cadastral Plan submission to our State Authorities.
However it is a requirement to suppress the trailing zeros, for example.
If the line length is 45.678 we need the line label to display 45.68 (precision 2 places)
If the line length is 17.200 we need the line label to display 17.2 (precision 1 place)
If the line length is 32.000 we need the line label to display 32 (precision 0 places)
The functionality we require is the same as what a standard AutoCAD dimension style can achieve with the suppress trailing zeros check box.
We know we can construct 3 different civil 3d line label styles with the required precision setting, but this means we need 3 styles for every label we have and need to manually change the style to suit the line length.
Do you know of a way to achive this result using "Expressions"?
I figured writing out my solution here would be way too much so I wrote it up on my blog. You can read it HERE. You can't accomplish this with one component in your label because there is no way to control the precision. My solution is basically to test if the value rounded to the ones place is the same as if it were rounded to the thousandths place. If it is, return the value, if not return -1. In the component, use this expression and hide negative values. Repeat for the tenths, hundredths, thousandths, ten thousandths, etc. as far out as you need to go.
As an FYI, this solution will only work if your values will never be less then zero. If you are trying to do this for something like cut and fill labels or slopes, it won't work.
Brian,
I have now worked through all of the expressions you provided on your blog site for this issue, and it works a treat!
I used slightly different names for my expressions that will be more meaningful to my users, and this works extremely well for me.
Thanks very much for your input here, it is highly valued.
Best Regards,
Jim Williams