See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Rounding up, down or to nearest... any interval

  1. #1
    All AUGI, all the time DoTheBIM's Avatar
    Join Date
    2005-02
    Location
    Central PA, USA
    Posts
    756
    Login to Give a bone
    1

    Default Rounding up, down or to nearest... any interval

    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
    Last edited by DoTheBIM; 2010-04-20 at 11:55 AM. Reason: Removed redundant calculation of *1

  2. #2
    Active Member
    Join Date
    2006-11
    Location
    Auckland, New Zealand
    Posts
    92
    Login to Give a bone
    0

    Default Re: Rounding up, down or to nearest... any interval

    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
    Last edited by MTristram; 2011-01-14 at 01:04 AM. Reason: added another point re sorting in schedule

  3. #3
    I could stop if I wanted to
    Join Date
    2006-10
    Location
    Redding, CA
    Posts
    430
    Login to Give a bone
    0

    Default Re: Rounding up, down or to nearest... any interval

    Quote Originally Posted by mkt792314 View Post
    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. .-)

  4. #4
    Member
    Join Date
    2007-04
    Posts
    16
    Login to Give a bone
    0

    Default Re: Rounding up, down or to nearest... any interval

    Excellent post, thank you very, much.

  5. #5
    Member
    Join Date
    2006-10
    Posts
    6
    Login to Give a bone
    0

    Default Re: Rounding up, down or to nearest... any interval

    Quote Originally Posted by antman View Post
    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.

  6. #6
    AUGI Addict cdatechguy's Avatar
    Join Date
    2006-10
    Location
    CdA, ID
    Posts
    1,533
    Login to Give a bone
    0

    Default Re: Rounding up, down or to nearest... any interval

    Of course then Autodesk fixes all of this and makes a parameter to do this for us with 2012...
    Michael "MP" Patrick
    "I only drink :coffee: until it's acceptable to drink :beer: or :whiskey: or :wine:"

  7. #7
    All AUGI, all the time DoTheBIM's Avatar
    Join Date
    2005-02
    Location
    Central PA, USA
    Posts
    756
    Login to Give a bone
    0

    Default Re: Rounding up, down or to nearest... any interval

    Quote Originally Posted by cdatechguy View Post
    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.

  8. #8
    AUGI Addict MikeJarosz's Avatar
    Join Date
    2015-10
    Location
    New York NY
    Posts
    1,497
    Login to Give a bone
    0

    Default Re: Rounding up, down or to nearest... any interval

    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?

  9. #9
    All AUGI, all the time JoelLondenberg's Avatar
    Join Date
    2015-10
    Posts
    508
    Login to Give a bone
    0

    Default Re: Rounding up, down or to nearest... any interval

    Quote Originally Posted by cdatechguy View Post
    Of course then Autodesk fixes all of this and makes a parameter to do this for us with 2012...
    What parameter...I missed it!

  10. #10
    All AUGI, all the time DoTheBIM's Avatar
    Join Date
    2005-02
    Location
    Central PA, USA
    Posts
    756
    Login to Give a bone
    0

    Default Re: Rounding up, down or to nearest... any interval

    Quote Originally Posted by jlondenberg View Post
    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.

Page 1 of 2 12 LastLast

Similar Threads

  1. 2013: Rounding to nearest .5 in schedules
    By jplatte in forum Revit MEP - General
    Replies: 8
    Last Post: 2013-04-08, 06:30 PM
  2. Rounding to the nearest integer in Tables
    By kkinchen in forum AutoCAD Tables
    Replies: 1
    Last Post: 2007-04-26, 04:23 PM
  3. Rounding up to the nearest 5
    By ReachAndre in forum AutoLISP
    Replies: 7
    Last Post: 2007-01-29, 06:56 PM
  4. Can a dialog appear at a specified time interval?
    By GreyHippo in forum AutoLISP
    Replies: 19
    Last Post: 2006-02-21, 05:38 PM
  5. Save reminder interval
    By kimheaver in forum Revit Architecture - Wish List
    Replies: 0
    Last Post: 2004-11-17, 02:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •