PDA

View Full Version : Rounding up, down or to nearest... any interval



DoTheBIM
2009-01-21, 05:35 PM
I just wanted to share what I've had to setup in one of my families. There are a few rounding threads out there, but none really addressed what I needed fully. I needed to round up to the nearest 6". What I ended up with was being able to round to any desired interval, up or down or either direction.

You need 3 parameters added (or calculated values if using schedules):

RoundingInterval as Length (or could be another type if rounding volume, currency, decimal numbers, etc. <should match the type of value you are trying to round)
NumberOfIntervals as Integer
RoundedValue as Length (should match type of RoundingInterval)

To Round up...Then your formulas should be similar to this to :
ActualValue will = the parameter value your trying to round

RoundingInterval = 0' 6" (Set this to any interval you need to round to, 1/16", 3", 8.75", 1' 6"... whatever)
NumberOfIntervals = (ActualValue + (RoundingInterval / 2 - 0' 0 1/256")) / RoundingInterval
RoundedValue = RoundingInterval * NumberOfIntervals

To Round down... change NumberOfIntervals formula to match this:
NumberOfIntervals = (ActualValue - (RoundingInterval / 2 - 0' 0 1/256")) / RoundingInterval

To Round either direction... change NumberOfIntervals formula to match this:
NumberOfIntervals = ActualValue / RoundingInterval

Hope this helps someone save some time searching and experimenting. Enjoy

MTristram
2011-01-14, 12:18 AM
What is the best way of achieving the following:

I have various numbers from a width field within a schedule ending in .67, .33, .97, .4 and want them to round either up or down to the nearest whole number. I also want to be able to then sort the schedule with the whole numbers, currently even though we have the decimal point value set to zero it still looks at the actual number for sorting (understandable or confusing?)

I guess if I actually sat down and concentrated for 5 mins I'd be able to work it out - any help is appreciated.

wouldn't it be great if Revit had the 'Round' functionality of Excel

antman
2011-01-17, 04:30 PM
What is the best way of achieving the following:

I have various numbers from a width field within a schedule ending in .67, .33, .97, .4 and want them to round either up or down to the nearest whole number. I also want to be able to then sort the schedule with the whole numbers, currently even though we have the decimal point value set to zero it still looks at the actual number for sorting (understandable or confusing?)

I guess if I actually sat down and concentrated for 5 mins I'd be able to work it out - any help is appreciated.

wouldn't it be great if Revit had the 'Round' functionality of Excel

Subtract 0.5 and round up. .-)

Mike_S_Jones
2011-03-16, 04:09 PM
Excellent post, thank you very, much.

william_cooper
2011-10-21, 10:38 PM
Subtract 0.5 and round up. .-)

and if you want it to disregard direct hit round numbers subtract 0.00001 if you are rounding up and add 0.00001 if rounding down.

cdatechguy
2011-10-22, 02:49 AM
Of course then Autodesk fixes all of this and makes a parameter to do this for us with 2012...

DoTheBIM
2011-10-24, 12:03 PM
Of course then Autodesk fixes all of this...Partially fixed... you still can't round to a desired fraction/decimal/multiple without using a method similar to the the first post in this thread. All they did was make rounding to whole numbers easier.

MikeJarosz
2011-10-24, 06:34 PM
Suggestion: try this in Excel to get a feel for how it works. If you know Excel VBA, even better!

Question: 2000 views? 6 answers?

huh?

JoelLondenberg
2011-12-06, 01:04 AM
Of course then Autodesk fixes all of this and makes a parameter to do this for us with 2012...

What parameter...I missed it!

DoTheBIM
2011-12-06, 01:01 PM
What parameter...I missed it!See "Round", "Roundup" and "Rounddown" formulas in the help file, or on the wiki help. Only solves some of the most basic rounding things one might want to do.

traci
2013-03-20, 02:36 PM
Can the rounding functions be used in a calculated value field of a schedule? If so how?!

CADastrophe
2013-03-20, 03:07 PM
Can the rounding functions be used in a calculated value field of a schedule? If so how?!

When you are defining the Calculate Value, you can use the ROUND function in "Formula:" and specify a field to round.

---------------------------------------------------------------

Rounding to a specifc increment can be accomplished using the following formulaic method:

= round( Parameter / X) * X

Where X = desired rounding increment.

Examples:

Value: 12672.1 to be rounded to the nearest 10
Formula: = round( Parameter / 10) * 10
Walk-through: 12672.1 / 10 = 1267.21, rounded = 1267.0, * 10 = 12670

Value: 33.318 to be rounded to the nearest 0.5
Formula: = round( Parameter / 0.5) * 0.5
Walk-through: 33.318 / 0.5 = 66.636, rounded = 67, * 0.5 = 33.5

And welcome to the forums, by the way. :beer: