room area macro rounding


robdyck
 Share

Go to solution Solved by Chopsaw,

Recommended Posts

I'm attempting to use the room internal area to perform a simple calculation which I need rounded to a whole number. No matter I try, I can't accomplish this. I always get decimals or a zero. I need the following info:

  • room area divided by 50 
  • room area divided by 100

And I need the results in whole numbers...any help is appreciated.

 

A 120 sq ft room gives the following result:

  • %room.internal_area/50% = 2.4

  • %room.internal_area*0.02% = 2.4

  • %room.internal_area*0.02.round% = 0

  • %room.internal_area*0.025649518.round(4)% = 3.072 (just a random experiment)

 

 

Link to comment
Share on other sites

  • Solution

Hi Rob,  I think you are running into issues just with your structure.  You need to do your calculation then round.

 

%(room.internal_area/50).round%   or   %(room.internal_area/50).ceil%  or   %(room.internal_area/50).floor%

 

Does that look correct Joe  ?

  • Upvote 1
Link to comment
Share on other sites

25 minutes ago, Chopsaw said:

Hi Rob,  I think you are running into issues just with your structure.  You need to do your calculation then round.

 

%(room.internal_area/50).round%   or   %(room.internal_area/50).ceil%  or   %(room.internal_area/50).floor%

 

Does that look correct Joe  ?

Yes

  • Upvote 1
Link to comment
Share on other sites

1 hour ago, robdyck said:
  • %room.internal_area*0.02.round% = 0

  • %room.internal_area*0.025649518.round(4)% = 3.072 (just a random experiment)

 

Chopsaw gave you a solution, but just to clarify, in the above 2 examples, what you're doing is rounding 0.02 down to 0 and 0.025649518 down to 0.0256.  When I'm teaching people to use ruby scripting, one of the first things I typically recommend is that they always encapsulate their various calculations in parentheses whether it seems necessary or not in order to be sure that the calculations are being carried out like you want them to.  In other words, make it very clear to ruby what you are doing to what.  I want to take this>>>> (room.internal_area*0.02) and then round that whole thing. 

  • Like 1
Link to comment
Share on other sites

5 hours ago, Alaskan_Son said:

 

Chopsaw gave you a solution, but just to clarify, in the above 2 examples, what you're doing is rounding 0.02 down to 0 and 0.025649518 down to 0.0256.  When I'm teaching people to use ruby scripting, one of the first things I typically recommend is that they always encapsulate their various calculations in parentheses whether it seems necessary or not in order to be sure that the calculations are being carried out like you want them to.  In other words, make it very clear to ruby what you are doing to what.  I want to take this>>>> (room.internal_area*0.02) and then round that whole thing. 

Thanks Michael. A logical explanation. Appreciated! A little context... I'm working on a commercial project and I want to calculate the # of occupants based on various room types. I had added an accessory to the Components for the room types, but I wanted live updating as the design develops (in a room label). 'Cuz toilets are based on the number of butts in the building!

Any thoughts on the simplest way to get a value like that into a room schedule? Note Schedule I assume? That's what I've used in the past.

  • Upvote 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share