How to use formulas in parameters | Revit Tips #17

You can use formulas in Revit to combine multiple parameters and get a new value based on these parameters values. Having the knowledge of how to use formulas are important when you create schedules and especially families.

You don’t need to have some programming skills in order to write formulas in Revit. In fact, you only need to know basic mathematical operations that you learned in elementary school.

Syntax of formulas

In order to use formulas you need to know its syntax. You can use standard mathematical syntax and IF conditional statements with or without AND/OR functions. Start with simple formulas, then create more complex one. You can create formulas in schedules and in families.

  • Basic formulas. The basic formulas use mathematical operations such as add, subtract, multiply, divide. You can also use exponentiation, logarithms, and square roots, as well as trigonometric functions and round function. Example formats:

    “Parameter 1” = “Parameter 2” + 10 mm
    “Parameter 1” = sqrt(“Parameter 2” * “Parameter 3”)
    round(5.8) = 6
    rounddown(5.8) = 5

  • IF statements. IF statement are formulas that use conditional statements in format:

    if(“condition”, “true”, “false”)

    • Embedded conditions. More complex IF statements can be created if you have embedded IF statements in place of “true” and “false”. These formulas are harder to read. They use the following format:

      if(“condition”, if(“condition”, “true”, if(“condition”, “true”, “false”)), “false”)

    • AND and OR functions. You can create the condition from two or more conditions using AND and OR functions. The AND function means all the conditions are met; the OR function means any of the conditions is met. This formula is in the following format:

      if(and(“condition 1”, “condition 2”), “true”, “false”)
      if(or(“condition 1”, “condition 2”), “true”, “false”)

    • Yes/No parameters. Yes/No parameters are checkbox parameters that can have only two values. So they don’t require full IF statement formulas but only the condition, and the AND and OR functions can also be used here. The example formats of these formulas:

      not(“Yes/No parameter”)
      “Yes/No parameter”
      and(“condition 1”, “condition 2”)

Formulas in schedules

You need to pay particular attention to units as logically you cannot mix different units. All units used in formulas should be consistent with units defined by the selected type. In your formula you can use only parameters that you have included in your schedule.

  1. Open Schedule Properties dialog and click “Add calculated parameter” button. You will open “Calculated Value” dialog box.
  2. Enter the Name of the new parameter, and select the Type to determine the units used in formula. Make sure that you select the correct Type, for example for length you should choose the Length type, and not the Number type.
  3. Write your formula with parameters you previously added to the schedule.
    Examples:

    Type: Length, Formula: Width + 10 cm
    Type: Area, Formula: Width * Height

How to use formulas in parameters - Screenshot 1

Formulas in families

You will usually use more complex formulas in families than in schedules.

  1. Open a family.
  2. Click “Family Types” button to open a dialog box. You will see Parameter, Value and Formula columns.
  3. Add new family parameters and assign formulas to parameter values.

For example, maybe you want to set the “Rough Width” parameter in a door family in relation to the other parameter “Width”.
Example:

Rough Width = Width + 10 mm

This way you will automatically calculate value for Rough Width parameter. If you enter the value “1000” for Width, the value for “Rough Width” will be “1010”.

If you want to set the “Rough Width” parameter to have value that is driven by conditions you will use IF statement. Which value will be used depends on the value entered in the “Width” parameter.
Example:

Rough Width = if(Width < 2000, Width + 10 mm, Width + 20 mm)

Let’s suppose that the “Width” parameter has the value 2200. This formula will automatically calculate value for the “Rough Width” parameter to be 2220 because the condition is false so it uses the second formula. You can also use a simple value instead of formula here.

If you have several conditions you can use embedded conditions.
Example:

if(Width < 2000, Width + 10 mm, if(Width > 2400, if(Width > 2600, Width + 35 mm, Width + 30 mm), Width + 20 mm))

You can use AND/OR functions with your conditional statements.
Examples:

Rough Width = if(and(Width < 2000, Height < 2000), Width + 10 mm, Width + 20 mm)
Rough Width = if(or(Width < 2000, Height < 2000), Width + 10 mm, Width + 20 mm)

How to use formulas in parameters - Screenshot 2

admin

Leave a Reply

Your email address will not be published. Required fields are marked *