Tuesday, 14 July 2015

Setting Maximum and Minimum Values

When you are creating Families in Revit there is often times where you would like to set maximum and minimum values for a parameter. This can be done using a simple nested ‘If’ statement in the formula.

In the example we would like to specify a maximum and minimum range for a length of an object. For this we will need 2 parameters….

Length – this parameter is the adjustable length of the object in question, this can be set to any amount without limitation. (For example this could be used to describe the distance from the object to a reference point)
Length Actual – This is the actual length of the object that is limited to a maximum and minimum amount.

The Length parameter is manually input (or determined) by the user.

The Length Actual then needs a formula applied to set it maximum and minimum values, in this example we are going to set a maximum amount of 2400 and a minimum amount of 1200.

The formula for Length Actual would read…..

=if(Length < 1200, 1200, (if(Length > 2400, 2400, Length)))

This formula reads….

If the Length is less than 1200 then use 1200, if the Length is greater than 2400 then use 2400, if the Length is between 1200 and 2400 then use the Length value.

(The ‘mm’ units get automatically added by Revit)

Wednesday, 1 July 2015

Formulas - Yes or No Driven by If Statements

When you need to have a Yes or No Parameters enabled by other parameters in your family. Usually you use ‘If’ statements to apply conditions…. Like shown below….

= if (Area  > 1m²)

In the Case of a Yes/No Parameter, you aren’t required to write the ‘if’ part of the formula or the brackets. Just make the statement and Revit will do the rest.

The Example below has 2 sets of formulas both normally would be written with an ‘if’ statement, but in the case of a Yes/No, they are written without. (The top one is an ‘and’ statement requiring both variables to be true for the Yes/No to work.