BIM World
A Professional BIM Learning Platform


Understanding Conditional Statements in Revit Formulas

Using Conditional Statements in Revit Formulas

Conditional statements allow Revit to assign parameter values based on whether specific conditions are met. While these statements can be very useful, they also add complexity to families and should be used only when necessary.

For most type parameters, conditional statements are generally unnecessary because a type parameter inherently acts like a conditional: if it’s a certain type, then set the parameter to a specified value. Instance parameters, on the other hand, are better suited for conditional statements—especially when setting parameters that don’t change continuously.

Revit Formula Syntax for Conditional Statements

The basic structure of a conditional statement in Revit formulas is as follows:
IF(condition, value_if_true, value_if_false)

This means the parameter value depends on whether the condition is true or false. If the condition evaluates to true, Revit returns the first value; if false, it returns the second.

Conditions can involve numerical values, parameter names, or Yes/No parameters. The following comparison operators are valid: <, >, =. Boolean operators such as AND, OR, and NOT are also supported. Note that <= and >= are not directly supported; instead, you can express them using NOT, for example: a <= b can be written as NOT(a > b).

Common Conditional Statement Examples in Revit (Angle Class)

Here are some example formulas using conditional statements:

  • Simple IF statement:
    =IF(Length < 3000mm, 200mm, 300mm)
  • IF with text parameters:
    =IF(Length > 35', "String1", "String2")
  • IF with logical AND:
    =IF(AND(x=1, y=2), 8, 3)
  • IF with logical OR:
    =IF(OR(A=1, B=3), 8, 3)
  • Nested IF statements:
    =IF(Length < 35', 2' 6", IF(Length < 45', 3', IF(Length < 55', 5', 8')))
  • IF with Yes/No condition:
    =Length > 40 (Both condition and result are implicit)

Practical Uses of Conditional Statements

Conditional statements are often used to calculate array values or control the visibility of graphical elements based on parameters. For example:

  • Preventing array parameters from being less than 2:
    In Revit, array values must be integers greater than or equal to 2. You can use a conditional formula to ensure the array parameter never falls below 2, even if the calculated value is 1 or 0. The formula below retains values equal to or greater than 2, but changes values below 2 to 2.
    Array number = IF(Arrayparam < 2, 2, Arrayparam)
  • Controlling window pane visibility based on the number of lights:
    Suppose you have a parameter called Lights which controls the visibility of the muntinVis geometry. You can create a Yes/No parameter named MuntinVis and assign it to the element’s visibility settings. Since MuntinVis is a Boolean parameter, the IF condition and result are implicit. When the condition (Lights > 1) is true, the window pane is visible; otherwise, it is hidden.
    Formula:
    MuntinVis = Lights > 1

Formulas and Units in Revit

Revit formulas operate on several data types:

  • Numbers with units
  • Boolean values (Yes/No)
  • Strings (text)

When calculating dimensions, unit errors usually arise from not following the proper unit rules.

Examples:

  • Addition requires inputs and results to have the same unit type.
  • Multiplication supports inputs of different unit types, but the result’s unit is the product of the inputs (e.g., length × area = volume).
  • The Sin() function takes an angle as input and outputs a unitless number.
  • The first parameter of IF() must be Boolean. The other parameters and results can be any data type (number, Boolean, or text), but all must be consistent.

Revit follows basic physical dimension standards such as time, length, volume, and temperature. Dimensional analysis is independent of the specific measurement units used (seconds, meters, kilograms, degrees Celsius, etc.).

Formulas and Constants

Incorrect dimensions often stem from how numerical constants are interpreted in formulas.

If a formula contains parameters or constants with explicit units (e.g., 5 kg), Revit clearly recognizes the unit. However, if a number is entered without a unit (e.g., 5), Revit guesses the unit to match the formula. To avoid confusion, it’s a common practice to multiply or divide by 1 with a specified unit.

Best practice: always specify units for constants in formulas.

Example:

  • If you want the result to be a length, entering 3 * 3 will cause Revit to guess one number as length and display it as 3' * 3.
  • Entering 3 * 3 kg / 3 results in a unit inconsistency error. However, 3' * 3 kg / 3 works because Revit interprets the last constant as kg. This example mixes imperial and metric units; Revit will convert the formula to project units when edited, such as 3' * 6.614 lbm / 3 lbm.

Units for Constants

The following units are commonly used in constant formulas. This list is not exhaustive but covers frequently used types.

To use degrees for angles and temperatures, first input radians (rad) or Kelvin (K), then edit the formula; Revit will replace these with the project unit symbols (° for angles or temperatures).

Common Units in the United States

Unit Symbol
Length (feet) ft or LF
Inch
Square foot sf, ft²
Cubic foot cf, ft³
Seconds (time) s
Hours h
Pound mass lbm
Pound-force lbf
Thousand pounds (kip) kip
Radian rad
Fahrenheit temperature °F
Decimal degrees °
Thousand pounds per square inch ksi or kip/in²
Pounds per square inch psi, lbf/in², psia

SI Units (International System of Units)

Unit Symbol
Millimeter mm
Centimeter cm
Decimeter dm
Meter m
Kilogram kg
Celsius temperature °C
Kelvin temperature K
Newton N
Kilonewton kN
Meganewton MN
Pascal Pa
Megapascal MPa
xuebim
Follow the latest BIM developments in the architecture industry, explore innovative building technologies, and discover cutting-edge industry insights.
← Scan with WeChat
Like(0) 打赏
BIM WORLD » Understanding Conditional Statements in Revit Formulas

Comment Get first!

Must log in before commenting!

 

BIM World, A Professional BIM Learning Platform

Stay updated on the latest architecture trends and share new building technologies.

Contact UsAbout Us

觉得文章有用就打赏一下小编吧

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

Account Login

By signing in, you agree toUser Agreement

Sign Up