Share
 
 

Formula Examples

Review examples of how formulas are used to calculate values for parameters in a family.

The advanced sample family contains examples of different kinds of formulas and demonstrates how formulas can be used to calculate parameter values and control the geometry of the family. The sample family also illustrates the syntax for commonly-used formula types.

The advanced sample family (rac_advanced_sample_family.rfa) is installed with the product in this directory: %ProgramFiles%\Autodesk\Autodesk Revit 2026\Samples. Online users can also download the file from the Sample Family Files page.

The advanced sample family is a sun shading device placed above a window or windows in the project. The user defines parameters for how the shade family relates to the window. Based on formulas, the geometry of the shade is modified to provide shading for the window. The following images show 3D and elevation views of the shade family in a project.

Basic Math

These examples demonstrate basic math functions in formulas.

Parameter Formula
Shadow_Length
Mounting_Height-Window_Sill_Height
Rel_Angle
90º-Sun_Angle
Max Louver Spacing
Support_Length-(Support_Length*(Desired_Shading_Percent*0.01))
  • The Shadow_Length parameter is calculated by taking the mounting height of the family and subtracting the sill height.
  • The result is the length of shadow needed for the louver system to fully shade the window.
  • The Rel_Angle parameter is calculated by subtracting the sun angle from a constant, 90.

    This parameter will later be used in another formula using trigonometric functions to calculate the length of support needed to cast a shadow the length defined by the Shadow_Length parameter.

  • Max Louver Spacing is calculated based on how long the support will be and how much shade is needed.
  • The formula first converts a percentage into a decimal value, and then multiplies this value by the support length. The resulting value is the amount of the shade that needs to be covered with louvers.

Rounding and Trigonometric Function

The support length is calculated using a trigonometric function and then rounded up to the nearest millimeter (mm).

Parameter Formula
Support_Length
roundup((Shadow_Length/1mm)*tan(Rel_Angle))*1mm
  • The Support_Length required is a function of Shadow_Length multiplied by the tangent of the relative angle of the sun to the shading device, based on the time of year and the location of the project.

    These variable conditions will change the required length of support needed to fully shade the window.

  • The rounding function takes the calculated value and rounds it to the nearest mm. For the rounding function to work, the number being rounded must be unitless.
  • In the example formula, the length units are removed from the Shadow_Length parameter by first dividing the parameter by 1mm, and then making the calculation.
  • After the number is rounded to the nearest mm, the units are added back to the number by multiplying by 1mm.

Conditional Statements

Conditional statements can be used in a formula to check values of other parameters and return results based on those values. See Use Conditional Statements in Formulas for additional information. In the example, the Support_Hanger parameter is a yes/no parameter used to control the visibility of an additional support for the shade.

Parameter Formula
Support_Hanger
Support_Length>400mm
Shade_Factor
if(Desired_Shading_Percent<65,"Low",if(Desired_Shading_Percent<79,"Med",if(Desired_Shading_Percent<99,"High","Max.")))
  • Once the Support_Length parameter exceeds 400mm, the statement is true, the parameter value is set to "yes," and the additional support will be visible.

    When a conditional statement is used in a formula to define a yes/no parameter, the result if true and result if false are implied and do not need to be written in the syntax of the formula.

  • The Shade_Factor parameter uses a nested conditional statement to return 1 of 4 results, Low, Med., High, or Max.
  • The check is done against the Desired_Shading_Percent and, based on this value, returns the text result.
  • Each successive IF statement is checked. If the condition is not true, then the next IF statement is evaluated until a true result is found.

Array Formula

Arrays in a family can be controlled using an integer parameter.
Note: The formulas used in the example family were developed prior to the release of Revit 2025. Before 2025, it was necessary for the formula to include specific syntax ensuring that the array value would always be greater than one. This explains why each formula in our examples includes a '+1'.
Parameter Formula
Number of Supports
(Length/Max_Support_Spacing)+1
Louver Number
(Support_Length/Max Louver Spacing)+1
  • The Number of Supports parameter is a basic math function used to find the number of supports needed based on the spacing information and the total length of the shading element.
  • The Louver Number creates an array value to place louvers into the shade based on the length of the support and the spacing of the louvers needed.
  • Both formulas include an additional "+1" to insure the array value is always at least 2.
  • Because both of the parameters in this case are defined as integer parameters, the rounding function does not need to be included in the formulas.

Was this information helpful?