Introduction to Revit Formula

Introduction to Revit Formula

Posted 6th December 2016 by Connor Laing

In this new series, the content team at bimstore will be sharing some useful bits of info, along with tips and tricks to help Specifiers get the best out of BIM Objects.  If there is something you would like to see covered here in the future, then drop us a line and let us know!

Introduction to Revit Formula

To make the most of Revit’s parametric engine, you can use formulae to power your families. Doing this is a great way to increase the functionality of the components you are creating and if done correctly can really maximise user functionality! At bimstore we constantly incorporate formula into our families which power all kinds of parameters, from automatically calculating weight to calculating heat outputs. The possibilities are endless and you can really push the software to its limits using formulae if you know how.

STANDARD FORMULA:  These formulae are basic mathematic equations that can be used to power parameters.

(ADD, SUBTRACT, MULTIPLY, ETC.) can all be used to automatically calculate parameters.

EXAMPLE –  Say you have a component which has an  “OverallWidth” of 2000m. There is a space inside the component “InnerWidth” which is 200mm smaller than “OverallWidth”. To avoid adjusting 2 parameters when you want to change the size you can automatically calculate the size of the “InnerWidth”.

In the formula box in the parameter “InnerWidth” use the following: (OverallWidth -200mm). This will then automatically calculate the distance for you. See image below calculating the “InnerWidth” and “InnerLength”.

This principle can be used for any sort of mathematical calculation and it can include all maths functions in a single formula if needs be (just remember your BODMAS rules from school!)

CONDITIONAL STATEMENTS (BOOLEAN) - This is probably the most useful type of formula you will come across and it can be used in all kinds of scenarios. You can power almost any type of parameter using these rules. With these formulae you can use other mathematical items such as: “<” or “>” (greater than, less than) / “=” (equal to) to control part of the formula. See below:

“IF” FUNCTION:

IF (<condition>, <result-if-true>, <result-if-false>)

This condition statement starts with an “IF” in the formula box followed by a bracket to begin the formula.

You then go on to add the condition - so using the previous example – IF (OverallWidth < 500 mm … So far the formula says, IF the “OverallWidth” is LESS THAN 500mm …

Next we add the result if the statement is true. So the result if “OverallWidth” is LESS THAN 500mm - IF (OverallWidth < 500 mm, 25 mm …. So now we have, IF the “OverallWidth” is LESS THAN 500mm the result will be that the value of the parameter we are adding the formula to will be “25 mm”.

Finally, we add the result if the statement is false. So if “OverallWidth” Is MORE THAN 500mm what will the value be - IF (OverallWidth < 500 mm, 25 mm, 250 mm)

Close the formula with a bracket and there you have it! Always remember to use brackets correctly and add commas into the formula to separate each part of the formula.

 

You can also use “IF” statements to control loads of other parameter types using the same formula structure. Simply adapt to suit your needs. Note - if you are using the formula to control a text parameter, make sure you use speech marks (“ ”) to open and close the statement otherwise you will get an error message! E.g. =if(Length = 500 mm, “Length equals five hundred millimetres”, “Length doesn’t equal five hundred millimetres”)

“AND” FUNCTION:

IF (AND (<condition 1>, <condition 2>), <result-if-true>, <result-if-false>)

This condition statement starts with an “IF” in the formula box followed by a bracket to begin the formula. However, if 2 or more conditions are required to be included in the formula, we also use an AND statement. This means both of the parameters you add to the formula need to have the value specified to achieve the <result-if-true>.

You then go on to add the conditions, so using the previous examples – IF (AND (OverallWidth < 500 mm, OverallLength> 200 mm) … So far the formula says, IF the “OverallWidth” is LESS THAN 500mm AND “OverallLength” is MORE THAN 200 mm …

Next we add the Result if the statement is true. So the result if “OverallWidth” is LESS THAN 500mm AND “OverallLength” is MORE THAN 200 mm  - IF (AND (OverallWidth<500 mm, OverallLength>200 mm), 25 mm …. So now we have, IF the “OverallWidth” is LESS THAN 500mm AND “OverallLength” is MORE THAN 200 mm, the result will be that the value of the parameter we are adding the formula to will be “25 mm”.

Finally, we add the result if the statement is false. So if “OverallWidth” isn’t LESS THAN 500mm AND “OverallLength” isn’t MORE THAN 200 mm what will the value be - IF (AND(OverallWidth<500 mm,OverallLength>200 mm), 25 mm, 250 mm)

Close the formula with a bracket and there you have it! Always remember to use brackets correctly and add commas into the formula to separate each part of the formula.

 

Remember: BOTH values specified in the formula need to be met in order to read a true value. If just one value is true, the result will still be the false result.

You can use as many parameters as you like in the Condition section of the formula, just make sure you separate each condition with a comma “,” and also close the condition section with a bracket “)”

“OR” FUNCTION:

IF (OR (<condition 1> <condition 2>),<result-if-true>,<result-if-false>)

An “OR” statement would be used if the true result can be achieved by either condition value being true. The result will be false where neither parameter value matches the specified condition. The formula structure works the same way as the above “AND” statement - just replace the “AND” with “OR”)

 

EMBEDDED “IF” STATEMENT:

IF (<condition>,<result-if-true>, IF (<condition>,<result-if-true>, IF (<condition>,<result-if-true>,<result-if-false>)))

Embedded IF statements may look confusing, but they aren’t when you break them down. This type of formula would be used if there are multiple conditions that can give different true statements. Where standard IF statements use 1no condition, 1no result if true and 1no result if false, the embed option allows you to have as many conditions and results if true as you like. The result if false still remains at the end of the formula and is applicable if none of the previous conditions and results if true are specified.

Here is a worked example:

IF (Overall Width = 500 mm, 25 mm, IF(Overall Width = 550 mm, 100 mm, IF(Overall Width < 200 mm, 10 mm, 250 mm)))

What we have first is if “OverallWidth” = 500 mm the result is 25mm. Then we also have if “OverallWidth” =550mm the result is 100mm. Then we have if the “OverallWidth” is less than 200mm the result is 10mm. If the result is none if these options, the value is 250mm. Then we close the formula with the same number of open brackets as the number of Conditions in the formula).

 

This can be used in the majority of parameter types. Please note -  the condition part of the formula doesn’t have to be the same parameter every time like the above example.

TICK BOX PARAMETERS:

Tick box parameters can also be powered by these statements however they work slightly differently in that you don’t have to create a full statement. As the tick box is either ON or OFF there is no need to add the result if true or result if false.

In the formula box simply add in the condition statement in brackets. E.g. = (Length = 500 mm)

Another example. If you were using 2 conditions, you would have to add “AND” / “OR” whichever is suitable.

= and(Length = 500 mm, Width = 200 mm)

This article merely covers the basics at this stage however if you can master these techniques you will find you can add that extra something to components which sets you above the norm.

Watch out for more advanced formula examples in future!

About bimstore:
bimstore is the UK’s original BIM object library. Developed by specifiers for specifiers, we create and host high quality manufacturer specific BIM content, making it easy to browse and download the world’s best collection of BIM components. If you need any help with BIM content creation then get in touch with the bimstore team today.

Why not leave a Comment

This is your chance to have your say. Have you enjoyed using this article. Let us know!

Other peoples comments

x

Check out Bimstore Eye!

BimstoreEye is our new Augmented reality application for your phone or tablet, download it and watch bimstore content pop up from manufacturers literature! Download it now on iOS!

Mascot