Announcement

Collapse
No announcement yet.

Rounding a number in Family Parameter

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Rounding a number in Family Parameter

    Hi All,

    I'm trying to make the below rounded to .5. The Horsepower parameter property is set to Common/Number/Electrical_Loads but there is no Project Units or anything for me to format down the rounding. Also I've noticed that when I change the rounding to other things like Apparent Load below to 0 decimals, as you can see, it still maintains 2 decimal places.



    Attached Files

    #2
    If you're willing to use a Shared Parameter you can manage the rounding in the family, otherwise I think the rounding your referring to isn't really rounding but display rounding for schedules and the like. There would be nothing preventing you from entering .853942, for example.

    This should do the trick -- Horsepower_Rounded = round(Horsepower/0.5)*0.5 -- if you always need to round up you can change round to roundup. Similarly with rounddown.
    Greg McDowell Jr
    about.me/GMcDowellJr

    Comment


      #3
      Originally posted by GMcDowellJr View Post
      This should do the trick -- Horsepower_Rounded = round(Horsepower/0.5)*0.5 -- if you always need to round up you can change round to roundup. Similarly with rounddown.
      For clarification (this took me a while to figure out) dividing, then multiplying will set the rounding value in your formula. In the example above it is rounding to the nearest 0.5. If the divide/multiply was 0.25 you would round to the nearest 0.25, if it is 1 it will go to the nearest whole number.

      round(Horsepower/0.5)*0.5
      =1.5
      round(Horsepower/0.25)*0.25
      =1.25
      round(Horsepower/0.125)*0.125
      =1.125
      round(Horsepower/1)*1
      =1

      :thumbsup:
      Revit for newbies - A starting point for RFO


      chad
      BEER: Better, Efficient, Elegant, Repeatable.

      Comment


        #4
        And, of course, you can swap the number for a parameter and change it on the fly from within the project. Super useful.


        Sent from my iPhone using Tapatalk
        Greg McDowell Jr
        about.me/GMcDowellJr

        Comment

        Related Topics

        Collapse

        Working...
        X