h1

Working with Formulas in Revit

February 6, 2011

There’s a nice synopsis on Revit formulas and syntax at:
http://revitfamilies.blogspot.com/2005/10/revit-formulae.html

Thanks to Mike Hardy Brown for the post.  Partially duplicated below incase we lose the link.

_______________________

TIP: Keep your units consistent. Do not mix units in your formulas. You can use constants with no units assigned to them.

Length = Height + Width + sqrt(Height*Width)
Length = Wall 1 (11000mm)+ Wall 2 (15000mm)
Area = Length (500mm) * Width (300mm)
Volume = Length (500mm) * Width (300mm) * Height (800 mm)
Width = 100m * cos(angle)
x = 2*abs(a) + abs(b/2)

Create the family geometry.

Create and label dimensions to the geometry. See Labeling Dimensions. Do not select the Instance Parameter option. In the Family Editor, formulas are available for type parameters only.
Click Family Types from the Design Bar.
In the Formula column next to the appropriate parameter, type the formula for the parameter. Notice that the formula begins with an equal sign (=).

Formulas can comprise conditional statements. You enter conditional statements in the Formula box for a numerical parameter.

A conditional statement uses this structure:

IF (, , )

This means that values are entered for the parameter, depending on whether the condition is satisfied (true) or not satisfied (false). If the condition is true, return the true value. If the condition is false, return the false value.

Conditions can use numeric values, numeric parameter names, or Yes/No parameters. You can use the following comparisons in a condition: <, >, =. You can also use Boolean operators with a conditional statement: AND, OR, NOT. Currently, <= and >= are not implemented. To express such a comparison, you can use a logical NOT. For example, a<=b can be entered as NOT(a>b).

The following are some sample formulas that use conditional statements.

Simple IF: =IF (Length < 3000mm, 200mm, 300mm)

IF with logical AND: =IF ( AND (x = 1 , y = 2), 8 , 3 )

IF with logical OR: =IF ( OR ( A = 1 , B = 3 ) , 8 , 3 )

IF with Yes/No condition: =IF (Long, 50, 60) where Long is a Yes/No parameter defined as Long = Length > 40

Embedded IF statements: =IF ( Length < 35′ , 2′ 6″ , IF ( Length < 45′ , 3′ , IF ( Length < 55′ , 5′ , 8′ ) ) )

The following are valid formula abbreviations.

Addition— +
Subtraction— –
Multiplication—*
Division—/
Exponentiation—^: x^y, x raised to the power of y
Logarithm—log
Square root—sqrt: sqrt(16)
Sine—sin
Cosine—cos
Tangent—tan
Arcsine—asin
Arccosine—acos
Arctangent—atan
e raised to an x power—exp
Absolute Value—abs

Driving Revit Functionality
Carl

Leave a comment