Search
• Nick Fuller

# Parametric Formulas in Revit

Let's face it, the process of engineering a building is extremely complex. The elements and equipment that go into them, even more complicated. Developing content to represent all their variations can at times seem impossible. The parametric nature of Revit enables us to model our buildings with incredible detail and flexibility. Successful Revit content hinges on well written formulas that empower our models to morph as our designs evolve.

Understanding how to leverage those complicated formulas can be very difficult. Over the last decade I've been blessed to work with some very talented people that have taught me how to author those formulas and at times strong-arm Revit into submission. In the following post I'll share some of the things I've learned as well as some tricks I've picked up along the way.

The IF Statement

Probably the most powerful instrument you can employ in the parametric toolset. The IF statement can be leveraged to evaluate if a range of conditions are true. Take for example dimensional analysis, if a length parameter meets this condition, then do this or do that. In the example below, if the Width = 1'-0", then the result will be 1", if not the result will be 2". The syntax of the IF statement is this;

if(<Logical Test>, <Result If True>, <Result If False>)

Note the opening parenthesis, then the test followed by a comma, then the result if true followed by another comma, the result if false and then finally a closing parenthesis.

if (Width = 1'-0", 1", 2")

What if we want to check if our length is less than a certain length, or greater than a certain length?

Less Than a Value

If (Width<1'-0", 1", 2")

Greater Than a Value

If (Width > 1'-0", 1", 2")

The Nested IF Statement

Well what if we want to check for more than one condition, perhaps if one of a couple different conditions are true? What if we want to test if the length is 1'-0" or 2'-0" or perhaps within an acceptable range of values?

Checking for One of Two Values

If (or (Width = 1'-0", Width = 2'-0"), 1", 2")

Checking for Values Within a Range

If (and (Width>1'-0", Width < 2'-0"), 1", 2")

What if we want to only accept entries from an acceptable list? This is an especially powerful statement in that we are able to continue adding approved values without adding additional nesting.

Checking for a List of Acceptable Values

If (or (Width = 1'-0", Width = 2'-0", Width = 3'-0"), 1", 2")

One of the great things we can do with an IF statement is provide the end-user feedback on their entry, in essence tell them if their input is valid.

Providing User Feedback

If (or (Width = 1'-0", Width = 2'-0", Width = 3'-0"), "VALID ENTRY", "INVALID ENTRY")

The Toggle

One of the simplest tricks you can do with formulas is having alternate conditions oppose one another. Check boxes are great, but when you want one to be off when another is on you'll need to do this with a NOT function. Here's a really simple example.

What if you want to evaluate a conditional statement and then have checks toggle on or off? The IF statement for a Yes/No parameter is a little trickier than some other parameter types. Here is an example of how it can be written.

IF Statement for Yes / No Parameters

If (or (Width = 1'-0", Width = 2'-0", Width = 3'-0"), 1=1, 1=0)

Rounding

The Round function returns a value that is rounded to the nearest whole number without applying a rounding direction, like up or down. For example, if the number is 2.4 the result of the round function will be 2. If the number is 2.5 the resulting number will be 3. The round function can be applied to a wide array of statements.

Roundup and Rounddown function exactly the same as Round expect applying explicit rounding direction regardless of the input values.

There are nearly limitless ways you can leverage parametric formulas in Revit. I've tried to share a few of the tricks here that I've learned over the last decade or so developing custom Revit content. One thing I have learned is that you never stop learning, the moment you think you know everything someone comes along with a tip that completely blows your mind. Revit in its simplest form is just a tool to design buildings intelligently, the real magic happens when innovators find new ways to bend the software to their will.