Formulas in Takeoff
In Autodesk Takeoff, you can provide a formula that will be used to calculate a takeoff’s primary or additional quantities. A formula can also be used when providing model mappings.
Entering a Formula
When entering a formula for primary and additional quantities, you can include math operators, constants, and common math functions in it. For example:
$ 10 + PI / sin(100) $
When providing a formula for the model mapping, you can also provide model properties:
$ 10 + PI / sin(Height) $
In this case, when a takeoff is performed, the value of the given object’s property is used in the formula.
Note that there is no need for an equal sign (=) or other operator at the start of a provided formula in Takeoff.
Values for Formulas
Takeoff provides an autocomplete when entering a formula to help you discover which values can be used in the formula. Start typing in the formula field, and takeoff will suggest values based on your entry.
For Model Mappings, you must first select one or more objects in the viewer to have the object's properties included in the autocomplete suggestions.
You may select any property name, but the quantity will not be calculated if the object doesn’t have a property with the given name, or if it results in an invalid formula. For example, this would happen if the property has a string value, or results in a division by zero.
With an object from the model selected, use the Model Mappings menu to open Model Properties and see the available properties for the selected object. Preview the value of those properties to get a sense of what will be used when the formula is resolved to a value.
Properties used in the formula are displayed in bold in Model Properties.
Data Types
The most common data types used in formulas are numbers, constants, and within the Model Mapping formula, model properties.
Numbers can have various formats:
- 5
- 5.15
- 1.2e3 (equals to 1200)
- 22e-3 (equals to 0.022)
Although unlikely, numbers can also be expressed as octal, binary, or hexadecimal:
- 0b11 (equals to 3)
- 0o77 (equals to 63)
- 0xff (equals to 255)
Conditional Expressions
Takeoff supports the use of conditionals, expressions that return one value if a given condition is true and a different one if the condition is false.
$$ Condition ? trueValue : falseValue $$
For example, you can indicate that a quantity of 10 should be used if the Height of an object is smaller than 10, and a quantity of 20 should be used otherwise:
$$ (Height > 10) ? 10 : 20 $$
The resulting quantities are expressions themselves, so you could change the property that is to be used depending on a condition:
$$ (Height > 10) ? Width : Depth $$
The preceding formula will resolve to the value of the Width object property if that object’s Height is larger than 10. Otherwise the value of the Depth property is used.
Constants
Takeoff supports several math constants. Constants can be used anywhere a number or variable can be used. For example:
$$ 10 * PI $$
$$ E * PI / 100 $$
$$ 50 + (1 / SQRT2) $$
The autocomplete feature can help you find the constants that are supported.
The complete list of constants can be found here: https://mathjs.org/docs/reference/constants.html
Math functions
You can take advantage of many mathematical functions (for example, using sin and cos).
The complete list of functions supported can be found here: https://mathjs.org/docs/reference/functions.html
Grouping
You can use parentheses to group elements and override the default precedence.
For example:
$$ 2 + 3 * 4 = 14 $$
$$ (2 + 3) * 4 = 20 $$
Math operators
Takeoff supports all math operators supported by mathjs. The list is extensive, but the main ones are:
Operator | Name | Syntax | Associativity | Example | Result |
---|---|---|---|---|---|
+ | Add | x + y | Left to right | 4 + 5 | 9 |
- | Subtract | x - y | Left to right | 7 - 3 | 4 |
- | Unary minus | -y | Right to left | -4 | -4 |
* | Multiply | x * y | Left to right | 2 * 3 | 6 |
/ | Divide | x / y | Left to right | 6 / 2 | 3 |
%, mod | Modulus | x % y | Left to right | 8 % 3 | 2 |
^ | Power | x ^ y | Right to left | 2 ^ 3 | 8 |
! | Factorial | y! | Left to right | 5! | 120 |
== | Equal | x == y | Left to right | 2 == 4 - 2 | true |
!= | Unequal | x != y | Left to right | 2 != 3 | true |
< | Smaller | x < y | Left to right | 2 < 3 | true |
> | Larger | x > y | Left to right | 2 > 3 | false |
<= | Smallereq | x <= y | Left to right | 4 <= 3 | false |
>= | Largereq | x >= y | Left to right | 2 + 4 >= 6 | true |
For the full list, see https://mathjs.org/docs/expressions/syntax.html#operators
Values: Perimeter and InnerPerimeter
The Perimeter and InnerPerimeter values used in a formula for an area takeoff output can be useful for calculating perimeter.
- Use the value 'Perimeter’ in a formula for an output definition of an area takeoff to calculate its exterior perimeter (excluding any cutout perimeters).
- Use 'InnerPerimeter’ to calculate the perimeter of only the cutout areas within another area takeoff.
- You can use the combined values 'Perimeter + InnerPerimeter’ to calculate both the exterior perimeter of an area and the perimeter of any cutout areas within the area.