Expressions/de

Seit der Version 0.16 ist es möglich, Modelleigenschaft durch Rechenformeln festzulegen und mit anderen Eigenschaften von der Benutzeroberfläche aus zu verknüpfen. Eingabefelder von Eigenschaften für Zahlen oder Größenangaben enthalten einen blauen Knopf. Wenn man auf dieses Symbol klickt oder das Gleichheitszeichen (=) eingibt, öffnet sich der Formeleditor für die entsprechende Eigenschaft.

A FreeCAD expression is a mathematical expression, following normal notation for the standard mathematical operators (+, -, *, and /) and functions as described below. In addition, the expression may reference other properties, and also use conditionals. Numbers in an expression may have an optional unit attached to it.

Operators and functions are unit-aware, and require valid combinations of units, if supplied. For example, 2mm+4mm is a valid expression, while 2mm+4 is not (the reason for this is that an expression like 1in + 4 will most likely be interpreted as 1in + 4in by humans, but all units are converted to the SI system internally, and the system is not able to guess this).

Unterstützte Funktionen
In expressions, the following functions are supported, taking one or two arguments: abs, acos, asin, atan, atan2, cos, cosh, exp, log, log10, mod, pow, sin, sinh, sqrt, tan, tanh, ceil, floor, trunc, and round.

Aggregate functions: min, max, count, sum, stddev, and average. Aggregate functions can take one or more arguments, separated by comma or semicolon. Arguments may include ranges (two cells separated by a colon), e.g =average(B1:B8). These are interpreted as the properties B1, B2, ... B8.

Trigonometric functions use degrees as its default unit; supply "rad" if you want them to use radians.

Die Konstanten pi und e sind vordefiniert.

Die bedingte Anweisung wird wie folgt benutzt: ''= Bedingung ? Wahr-Ergebnis : Falsch-Ergebnis''

Die Bedingung muss ein Ausdruck sein, der entweder 0 (für falsch) oder ungleich 0 für wahr ergibt. Die folgenden Vergleichsoperatoren stehen zur Verfügung: ==, !=, >, <, >=, und <=.

Formeln werden wie folgt eingegeben: 2 * Length, wobei "Length" eine Eigenschaft des Objektes ist, für das der Ausdruck gedacht ist.

Referenzen auf CAD-Daten
It is possible to use data from other parts of the construction in an expression. The syntax for a reference to a field is as follows: object.property. If the property is a compound of fields, they can be accessed by e.g object.property.field.

The following table shows some examples:

Document-wide global variables
There is no concept of global variables in FreeCAD at the moment. Instead, arbitrary variables can be defined as cells in a spreadsheet using the Spreadsheet workbench, and then be given a name using the alias property for the cell (right-click on cell). Then they can be accessed from any expression just as any other object property.

Cross-document linking
It's possible that you have a spreadsheet in one document and reference values from there in other documents.

Important note: You use a document's name to reference it from other documents. Now, when saving the document the first time you choose a certain file name and this is usually different to "Unnamed1" (or its translated version) and then the links are lost after reopening it. So, it's recommended to create first the master document, create a spreadsheet, save and close it. After reopening the name is set to the above file name. Afterwards you can still make changes and save the file but you shouldn't rename it.

Then create the further documents where you want to add expressions to. Assuming you named the master document "master" you can access an alias like this: master#Spreadsheet.Length

Unfortunately, the integrated checker is more confusing than helping because it always gives parser errors or claims that this or that doesn't exist. So, just continue on typing. When you are finished and the content is correct the OK suddenly becomes active.

Of course, it's up to you to load the corresponding documents later when you want to change anything.

Known issues / remaining tasks

 * The dependency graphs is based on the relationship between document objects, not properties. This means that you cannot provide data to and query the same object in e.g a spreadsheet, even though there are no cyclic dependency when just the properties are considered. As a work-around, use multiple spreadsheets, e.g one to drive your model, and one for reporting.
 * There is no expression manager implemented where all expressions in a document are listed, and can be created, deleted, queries, etc.
 * Open bugs/tickets for Expressions can be found in the FreeCAD Bugtracker Expressions category