Tutorials TakeoffCraft help Reference

Formula language

The rules for assembly quantity formulas - variables, operators, functions, rounding and every error message.

Written for TakeoffCraft 0.3. The same help is inside the app: press F1.

Assembly components get their quantity from a formula. A formula is a small arithmetic expression over the item's measured values. See Assemblies and formulas for worked examples.

Variables

Item typeVariableMeaning
LinearLTotal length
LinearHThe item's height
LinearAWall area, L × H
LinearNNumber of runs
AreaATotal net area (outlines minus cut-outs)
AreaPTotal perimeter, including cut-out edges
AreaHThe item's depth or thickness
AreaNNumber of areas
CountNThe count
  • Variables are in the item's units: see Units.
  • Upper and lower case are the same: l is L.
  • Only the variables of the item's own type work. P on a linear item gives "P" is not a measured value here. Use L, H, A, N.
  • An empty height or depth is 0.

Operators

WriteMeaning
+Add
- or −Subtract, or a negative value
* or ×Multiply
/ or ÷Divide
( )Group

Multiply and divide go before add and subtract: L * 2 + 4 is (L × 2) + 4. Use parentheses when in doubt.

Numbers can have decimals (1.333, .5) and exponents (1e3 = 1000). Spaces are ignored.

Functions

FunctionResultExample
ceil(x)Round up to a whole numberceil(67.5) = 68
floor(x)Round down to a whole numberfloor(67.5) = 67
round(x)Round to the nearest whole number, halves away from zeroround(2.5) = 3
round(x, d)Round to d decimals (0 to 10)round(3.14159, 2) = 3.14
min(a, b, …)The smallest valuemin(N, 10)
max(a, b, …)The largest valuemax(1, ceil(N / 12))
abs(x)The value without its signabs(-3) = 3

ceil and floor ignore tiny computer rounding noise, so a value that should be exactly 1 is never rounded up to 2.

Errors

A formula that cannot be read or worked out shows its error under the field, and the component is left out of the totals (the Quantities header says "Incomplete"). Messages:

MessageFix
Type a formula, like L or ceil(L / 1.333) + 1.The formula is empty.
"X" is not a measured value here. Use …Use one of the listed variables.
"X" is not a function here. Use ceil, floor, round, min, max, abs.Use one of those functions.
"#" is not allowed in a formula.Remove that character (units, %, $ and = are not allowed).
A ")" is missing. / There is a ")" without its "(".Balance the parentheses.
A value is missing before ")".Something like max(1, ): fill in the value.
The formula ends too soon.Something like L *: finish it.
Unexpected "…". Is an operator missing?Two values side by side, like 2L: write 2 * L.
ceil() takes 1 value.Give the function the right number of values.
round(x, digits) needs whole digits from 0 to 10.Use a whole number of decimals.
The formula divides by zero.Usually H is 0: set the item's height or depth.
The formula does not give a number.The result is too large to be a number.
That formula is too long (500 characters at most).Shorten it.

Safe by design

A formula can only do arithmetic with the variables and functions above. It cannot run code or read anything else, so a formula in a project file someone sends you is harmless.