Tuesday, November 27, 2012

Rounding Length Values

When you create formulas in the Family Editor or perhaps in a schedule you can use the relatively new Round, Roundup and Rounddown options. They are designed to be used for unitless values. How often do we use unitless values? Click if you want to read the info at Autodesk's WikiHelp.

The other night I wanted to divide a panel height but round off the result. Take a door panel that has 6 lites that are defined by equal height from the top of the panel for example. One approach would be to just make the spacing equal. In this case the last lite is where the "slop" is supposed to go by making the upper lites equal in size. This means that the last lite is a little different size but then the bottom rail can be changed regardless of the lite sizes, without altering them.

The formula ended up looking like this:


In plain English, I add the top and bottom rail height together, subtract that from the panel height, divide by the number of lites. The rounding is applied to that result and divided by the desired rounding unit (1") and finally to satisfy Revit's quirkiness multiply the result by 1" to redefine what the units are. A bit round about (pun intended) but got where I wanted to go in the end.

Quick tip: When you add a parameter, click Apply before trying to fill in a formula. Revit needs to "save" the parameter before you can start using a formula in it. You'll typically get a message: "Can't find solution for formulas for type", wrote about this back in 2009.

No comments: