# Formulas

Functions that can be used in formulas, especially for intermediate values:

**+ - \* /** The familiar operands for plus, minus, multiplied by, and divided by.

**()** Parentheses for nesting formulas.

**sin, cos, tan** The familiar trigonometric functions sine, cosine, and tangent. The angle must be specified in degrees (circle = 360°).

**asin, acos, atan** The familiar trigonometric functions arc sine, arc cosine, and arc tangent for calculating the angle in degrees (circle = 360°) from a side ratio.

**sqrt** Square-root function: sqrt(25) yields 5.

**^** Exponent. 5^2 (read as 5 to the power of 2) yields 25.

**Pi** Pi constant. The circumference of a circle with a diameter of 2.5 m is calculated as: 2.5\*Pi

**round** Rounding. Commercial rounding is used. round(2.4) yields 2.0, round(2.5) yields 3.0. If VAB should always be rounded up, the appropriate formula is: round(VAB+0.5). An important function when calculating distributions.

**abs** Absolute value, value without sign, that is, without minus.\
abs(25) yields 25, abs(-25) likewise yields 25. Important function for differences (distances) when it is not certain which of the two values is larger.

#### Formula editor

(14.01) In the formula editor, a list of the variables used in the formula is now displayed at the lower left. The description text is shown after each variable. If the variable is clicked, it is opened in the tree beside it and any associated help image is also displayed. This makes it much faster to review the formula content.

(V20.01) HRB editor: Display of current values in the formula editor: When a formula is opened in the formula editor, the current values of the variables are displayed in the variable list after the texts. At the top of the dialog, the result of the entire formula is shown. These displays are very helpful when checking formulas; it is quicker to see whether the issue lies with the current formula or whether a variable has an unexpected value. The display of values is only possible in the HRB editor, because only there are the system variables also populated.

#### All variables in the formula editor

(15.01) All formulas can be provided with conditions. Conditions can use not only numeric values, but also any other variable types, e.g. text. Therefore, all variables are now offered in the formula editor, not only variables with numeric formats.

### Conditional formulas, conditions

Conditions can be processed in formulas. This enables much more flexible formulas that respond to situations. For example, the number of required dot symbols can be reduced significantly.

Such a formula consists of three parts separated by semicolons:

**(condition);(formula for satisfied condition);(formula for unsatisfied condition)**

(14.03) Conditions can also be nested to cover more than 2 situations in a formula.

Examples:

**(condition 1);((condition 2);(2 satisfied);(2 not satisfied));(1 not satisfied)**

**(---------------*****1 satisfied-------------------*****)**

**(condition 1);(1 satisfied);((condition 2);(2 satisfied);(2 not satisfied))**

**(---------------*****1 not satisfied-------------*****)**

The nesting can be continued simultaneously in "satisfied" and in "not satisfied".

In the next level, nesting can again be continued. Example:

**(cond. 1);(1 sat.);((cond. 2);(2 sat.);((cond. 3);(3 sat.);(3 not sat.)))**

**(---------*****1 not satisfied----------------------------*****)**

**(---------*****2 not satisfied--------*****)**

#### Comparisons that can be used in conditions:

**=** is equal to. The value before and after the sign must match exactly.\
Example: VAB = 4 is satisfied if VAB is exactly equal to 4.

**!=** not equal to. The value before the sign must be different, that is, greater than or less than the value after the sign.\
Example: VAB!=4 is satisfied if VAB is greater than or less than 4.

**>** greater than. The value before the sign must be greater than the value after the sign.\
Example: VAB>4 is satisfied if VAB is greater than 4.

**>=** greater than or equal to. The value before the sign must be greater than or equal to the value after the sign.\
Example: VAB>=4 is satisfied if VAB is greater than or equal to 4.

**<** less than. The value before the sign must be less than the value after the sign.\
Example: VAB<4 is satisfied if VAB is less than 4.

**<=** less than or equal to. The value before the sign must be less than or equal to the value after the sign.\
Example: VAB<=4 is satisfied if VAB is less than or equal to 4.

#### Linked conditions, logical operators

Multiple conditions can be linked logically:

**&** logical **and**. All conditions linked with and must be satisfied. So if VAB must be greater than 4 and less than 8, the full expression is:\
(VAB>4)&(VAB<8)

**|** logical **or**. (V20.01) At least one of the conditions must be satisfied:

> . The | symbol is used as the or sign (as in C++). On the German keyboard, this is entered with AltGr+"<".
>
> . Here we use the normal or: If at least one of the two subconditions is satisfied, the entire or expression is satisfied. Both subconditions may also be satisfied. (With exclusive or, only one of the two would be allowed to be satisfied).

The logical operators **and** and **or** can also be used in combination. Here are examples of conditional formulas:

\[Example:]{.underline} **((V\_abc=a)|(V\_abc=b));(0.04);(0.16)**

If variable V\_abc has the value a **or** b, then the value is 0.04. In all other cases, the value is 0.16.

\[Example:]{.underline} **((V\_aa=a)|(V\_bb=b));(0.04);(0.16)**

If variable V\_aa has the value a **or** V\_bb has the value b, then the value is 0.04. The overall condition is also satisfied if both parts apply (V\_aa=a and V\_bb=b). In all other cases, the value is 0.16.

\[Example for simulating exclusive or:]{.underline} (**((V\_a1=0)&(V\_a2!=0))|((V\_a1!=0)&(V\_a2=0)));(0.04);(0.16)**

Of the variables V\_a1 and V\_a2, only exactly one may have the value 0; then the value is 0.04. In all other cases, the value is 0.16.

#### Options for nesting conditions

In conditional formulas, the conditions can be very deeply nested, for example:

> **(((V\_a1=0)&(V\_a2!=0))|((V\_a1!=0)&(V\_a2=0)));(0.04);(0.16)**

In conditional formulas, formulas may also appear in the conditions, for example:

> **(V\_a1=(1+2+V\_a2));(0.04);(0.16)**

In conditional formulas, the true/false parts (after the first or second semicolon) may also again contain complete conditional formulas and thus be further nested, for example:

> **(V\_a1=0);((V\_a2=0);(0.04);(0.16));(0.16)**

However, within a condition, a complete conditional formula must not be used.

So the following is not permitted:

> **(0.3<((0.4<0.5);(0.6);(0.1));(0.04);(0.10)**

As stated above, conditions themselves may be nested arbitrarily, and the individual parts (left and right of the comparison sign) may also contain formulas. However, a complete conditional formula may not appear again within the condition. Therefore, no semicolons may occur there.

Logically, these cases can be handled by rearranging the formula or, for better clarity, by breaking it down into several intermediate values.

#### Tolerance in numeric comparisons:

When comparing with the value of a calculation, it must be remembered that numbers are stored in the computer with very many decimal places. Instead of 1.0, the computer may therefore hold 0.99999999999 or 1.00000000000001. If you compare exactly to 1.0 (VA=1.0), the comparison may fail even though the condition is technically satisfied.

* For this purpose, a comparison can be made with a tolerance. To do this, the difference to the desired value is checked. If VA=1.0 is to be evaluated with a maximum tolerance of 0.01, then the difference must lie between -0.01 and +0.01. The condition can then be:\
  ((0.01>(VA - 1.0))&(-0.01<(VA - 1.0)))\
  To eliminate the sign, the abs function can also be applied to the difference.\
  (0.01>(abs(VA - 1.0)))
* In other cases, it is sufficient to compare with a safe value. In distributions, a count is often calculated. If, for example, the condition is that the count (VANZ) is greater than 3, then we do not compare with greater than 3, but with (VANZ>2.5). Then it does not matter whether the actual result for VANZ is 2.999999 or 3.0000001.

#### Texts in conditions, comparison for texts:

Texts can also be used for comparisons. In principle, variables of all units that do not represent a numeric value can be used: txt, Idnr., Enum, A-F, ...

The comparison value is written directly as text without special control characters. If, for example, the variable "**V\_Textvariable**" is to be equal to "*Test*", the comparison is: **(V\_Textvariable=Test)**

Texts are sorted alphabetically and can therefore also be compared using "greater than" and "less than". The text that comes first in alphabetical order is the smaller one: "**Aluminium**" is therefore "*smaller*" than "**Lead**".

If the condition is that a variable does not contain an empty text, then the value of the variable must be "greater" than " " (space): **(V\_Textvariable> )**. There is no notation for an empty text, so we must compare with the smallest possible text. The " " (space) appears very early in character sets; only control characters come before it. We must insert a character before the "**#**" because, traditionally, identification numbers of auxiliary components begin with "**#**".

#### Texts in conditions: special case oa1 file (IFC Premium)

In the conditions (= **Condition**) of the oa1 files, comparisons are made with system variables. The following must be observed:

> If the system variable is a number, it is written directly; example:\
> **Condition=(OH=1.23)**\
> However, if it is a text that begins with a number (only then), it must be written in quotation marks. Example:\
> **Condition=(IFCNAME="1.23")**

#### Lists and placeholders in conditions

(15.01) In conditions, a value could previously be compared with a single value. With the new options to query the storey (SWAKT) or the version/execution (AUSF), the use of lists and placeholders is appropriate.

\[List]{.underline}: If a condition applies only to the ground floor, it is **(SWAKT=GF)**. If it is to apply to the ground floor, upper floors, and top floor, the condition is **(SWAKT={GF\~UF\~AG})**. The list is enclosed in curly braces, and the separator is the tilde '\~'.

\[Placeholder]{.underline}: If a condition applies only to the wall type "AW WDVS - Standard", it is **(AUSF=AW WDVS - Standard)**. If it is to apply to all versions/executions that begin with AW, the condition is **(AUSF={AW\*})**. The expression is enclosed in curly braces; the wildcard is the asterisk '\*'. The following arrangements are supported:

> **ABC\*** Begins with *ABC*, any ending
>
> **\*ABC** Begins arbitrarily, ends with *ABC*
>
> **\*ABC\*** Contains *ABC* at any position

\[List and placeholder]{.underline}: Both options can also be combined. If the condition is to apply to all versions/executions that begin with AW or IW, the condition is **(AUSF={AW\*\~IW\*})**.

### Repetitions in formulas

Only in combination elements: In the coordinates of the position points of components, libraries, and subdrawings (V20.01), and the reference points of point symbols, repetitions can be defined:

* Each coordinate receives an entry in the form (**start value\~step\~count**). A count of 1 means that no step is executed, i.e. something is created only at the start value.
* If repetitions are defined, they must be generated in X, Y, and Z:

> **X(1.0\~0.1\~5)Y(0.0\~0.0\~1)Z(0.0\~0.0\~1)** Row along X with 5 elements, starting at 1.0 with a step size of 0.1
>
> **X(1.0\~0.1\~5)Y(0.0\~0.2\~4)Z(0.0\~0.0\~1)** Row along X with 5 elements, starting at 1.0 with a step size of 0.1, this row repeated 4 times along Y with spacing 0.2.

* With these repetitions, rows, grids, or 3D grids can be generated in a single step.

### Error message, reporting erroneous formulas

(V20.01) With the introduction of the new formula system, the error messages were also revised:

* The display of formula errors has been expanded:

> ▫ Formulas are optionally checked when opening files (HRB, combination elements, settings). If desired, this is first enabled in project management in the function *5-02-1 logging functions* by selecting the corresponding checkbox. The structure must be restarted for this to take effect.
>
> ▫ Where possible, the type of formula error and the affected formula are displayed. This message can be copied to the clipboard and then used in the search function of editors.
>
> ▫ The button in the message can be used to suppress the display of further errors. This then applies until the structure (or HRB editor) is restarted. However, the error message for division by 0 cannot be suppressed.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dietrichs.com/dietrichs-intelligent-documentation/docs-de-en/the-variable-system/formulas-and-texts/formulas.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
