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 2023 Release\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.
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)) |
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.
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 |
These variable conditions will change the required length of support needed to fully shade the window.
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."))) |
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.
Arrays in a family can be controlled using an integer parameter. When the array is controlled with a formula, the formula must contain syntax to ensure the array value is always greater than one (an array value must always be greater than 1).
Parameter | Formula |
---|---|
Number of Supports |
(Length/Max_Support_Spacing)+1 |
Louver Number |
(Support_Length/Max Louver Spacing)+1 |