Expressions/de: Difference between revisions

From FreeCAD Documentation
(Created page with "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: ==, !=, >, <, >...")
(Updating to match new version of source page)
(45 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<languages/>

Funktionen mit Mehrfachargumenten: min, max, count, sum, stddev, und average.
Funktionen mit Mehrfachargumenten können mit einem oder einer ganzen Reihe von Argumenten aufgerufen werden, jeweils durch ein Komma oder Semikolon getrennt. Die Argumente können Bereiche (Zwei Zellreferenzen getrennt durch einen Doppelpunkt) enthalten, z.B =average(B1:B8). Dies wird als Liste der Werte B1, B2, ... B8 ausgewertet.

{{Version/de|0.16}}
{{Version/de|0.16}}


Seit der Version 0.16 ist es möglich, Modelleigenschaften 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 [[Image:Sketcher_Expressions.png|24px]]. Wenn man auf dieses Symbol klickt oder das Gleichheitszeichen (=) eingibt, öffnet sich der Formeleditor für die entsprechende Eigenschaft.
It is now possible to drive properties using mathematical expressions. From the GUI, spin boxes or input fields, that are bound to properties contain a blue icon [[Image:Sketcher_Expressions.png|24px]]. Clicking on the icon, or typing the equal sign (=), brings up the expression editor for that particular property.

<div class="mw-translate-fuzzy">
Ein Rechenausdruck in FreeCAD ist ein mathematischer Ausdruck in der üblichen Schreibweise für die Standardrechenarten (+, -, * und /) und mathematische Funktionen (siehe unten). Zusätzlich können referenzierte Eigenschaften anderer Objekte und bedingte Ausdrücke verwendet werden. Zahlen in Rechenausdrücken können mit einer optionalen Einheit versehen sein.
</div>

Numbers may use either a comma ',' or a decimal point '.' separating whole digits from decimals.
When the decimal marker is used, it ''must'' be followed by at least one digit.
Thus, the expressions '''1.+2.''' and '''1,+2,''' are invalid, but '''1.0+2.0''' and '''1,0+2,0''' are valid.

The constants ''pi'' and ''e'' are predefined, and must be written in lowercase.

Die Rechenarten und Funktionen verstehen sich auf Einheiten und erfordern deshalb bei der Verwendung von Einheiten zulässige Einheitenkombinationen. 2mm+4mm ist zum Beispiel ein zulässiger Rechenausdruck, während 2mm+4 nicht zulässig ist. (Der Grund dafür ist, das ein Ausdruck wie 1in + 4 von Menschen wohl als 1in + 4in interpretiert wird, das System dies jedoch nicht erraten kann, da alle Einheiten intern in das SI-System konvertiert werden.)

== Supported Operators ==

The following operators are supported:
{| class="wikitable float-right mw-collapsible mw-uncollapsed"
!style="width: 33%;"|Operator
!style="width: 66%;"|Description
|-
| +
| [https://en.wikipedia.org/wiki/Addition Addition]
|-
| -
| [https://en.wikipedia.org/wiki/Subtraction Subtraction]
|-
| *
| [https://en.wikipedia.org/wiki/Multiplication Multiplication]
|-
| /
| [https://en.wikipedia.org/wiki/Division_(mathematics) Division]
|-
| ^
| [https://en.wikipedia.org/wiki/Exponentiation Exponentiation]
|}


<div class="mw-translate-fuzzy">
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.
Mehrere Argumente einer Funktion können entweder durch Semikolon (';') oder ein Komma <em>gefolgt von einem Leerzeichen</em> getrennt werden.
Im letzteren Fall wird das Komma nach der Eingabe in ein Semikolon konvertiert.
Wenn ein Semikolon verwendet wurde, ist kein nachfolgendes Leerzeichen erforderlich.
</div>


The following constants are supported:
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).
{| class="wikitable float-right mw-collapsible mw-uncollapsed"
!style="width: 33%;"|Constant
!style="width: 66%;"|Description
|-
| e
| [https://en.wikipedia.org/wiki/E_(mathematical_constant) Euler's number]
|-
| pi
| [https://en.wikipedia.org/wiki/Pi Pi]
|}


== Unterstützte Funktionen ==
== Unterstützte Funktionen ==


=== General Mathematical Functions ===
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.


Die nachfolgend aufgeführten mathematischen Funktionen sind verfügbar.
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.


Multiple arguments to a function may be separated by either a semicolon ';' or a comma <em>followed by a space</em> ', '. In the latter case, the comma is converted to a semicolon after entry. When a semicolon is used, no trailing space is necessary.
Trigonometric functions use degrees as its default unit; supply "rad" if you want them to use radians.


[https://en.wikipedia.org/wiki/Trigonometric_functions Trigonometric functions] use degree as their default unit. For radian measure, add '''rad''' following the <em>first</em> value in an expression. So e.g. '''cos(45)''' is the same as '''cos(pi rad / 4)'''.<br/>
These trigonometric functions are supported:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 33%;"|Function
!style="width: 33%;"|Description
!style="width: 33%;"|Value range
|-
| acos(x)
| [https://en.wikipedia.org/wiki/Inverse_trigonometric_functions#Basic_properties Arc cosine]
| -1 <= x <= 1
|-
| asin(x)
| [https://en.wikipedia.org/wiki/Inverse_trigonometric_functions#Basic_properties Arc sine]
| -1 <= x <= 1
|-
| atan(x)
| [https://en.wikipedia.org/wiki/Inverse_trigonometric_functions#Basic_properties Arc tangent]
| all
|-
| atan2(x, y)
| [https://en.wikipedia.org/wiki/Inverse_trigonometric_functions#Basic_properties Arc tangent] of ''x/y''
| all, except y = 0
|-
| cos(x)
| [https://en.wikipedia.org/wiki/Trigonometric_functions#Right-angled_triangle_definitions Cosine]
| all
|-
| cosh(x)
| [https://en.wikipedia.org/wiki/Hyperbolic_function#Trigonometric_definitions Hyperbolic cosine]
| all
|-
| sin(x)
| [https://en.wikipedia.org/wiki/Trigonometric_functions#Right-angled_triangle_definitions Sine]
| all
|-
| sinh(x)
| [https://en.wikipedia.org/wiki/Hyperbolic_function#Trigonometric_definitions Hyperbolic sine]
| all
|-
| tan(x)
| [https://en.wikipedia.org/wiki/Trigonometric_functions#Right-angled_triangle_definitions Tangent]
| all, except of x = n·90 with n = integer
|-
| tanh(x)
| [https://en.wikipedia.org/wiki/Hyperbolic_function#Trigonometric_definitions Hyperbolic tangent]
| all
|}

These functions for exponentiation and logarithmization are supported:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 33%;"|Function
!style="width: 33%;"|Description
!style="width: 33%;"|Value range
|-
| exp(x)
| [https://en.wikipedia.org/wiki/Exponential_function#Formal_definition Exponential function]
| all
|-
| log(x)
| [https://en.wikipedia.org/wiki/Natural_logarithm Natural logarithm]
| x > 0
|-
| log10(x)
| [https://en.wikipedia.org/wiki/Common_logarithm Common logarithm]
| x > 0
|-
| pow(x, y)
| [https://en.wikipedia.org/wiki/Exponentiation Exponentiation]
| all
|-
| sqrt(x)
| [https://en.wikipedia.org/wiki/Square_root Square root]
| x >= 0
|}

These functions for rounding, truncation and remainder are supported:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 20%;"|Function
!style="width: 55%;"|Description
!style="width: 25%;"|Value range
|-
| abs(x)
| [https://en.wikipedia.org/wiki/Absolute_value Absolute value]
| all
|-
| ceil(x)
| [https://en.wikipedia.org/wiki/Floor_and_ceiling_functions Ceiling function] smallest integer value greater than or equal to x
| all
|-
| floor(x)
| [https://en.wikipedia.org/wiki/Floor_and_ceiling_functions Floor function], largest integer value less than or equal to x
| all
|-
| mod(x, y)
| [https://en.wikipedia.org/wiki/Remainder Remainder] after dividing ''x'' by ''y''
| all, except y = 0
|-
| round(x)
| [https://en.wikipedia.org/wiki/Rounding Rounding] to the nearest integer
| all
|-
| trunc(x)
| [https://en.wikipedia.org/wiki/Truncation Truncation] to the nearest integer
| all
|}

<div class="mw-translate-fuzzy">
Die Konstanten ''pi'' und ''e'' sind vordefiniert.
Die Konstanten ''pi'' und ''e'' sind vordefiniert.
</div>


These aggregate functions are supported:
Die bedingte Anweisung wird wie folgt benutzt: ''= Bedingung ? Wahr-Ergebnis : Falsch-Ergebnis''
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 20%;"|Function
!style="width: 55%;"|Description
!style="width: 25%;"|Value range
|-
| average(x:y)
| [https://en.wikipedia.org/wiki/Arithmetic_mean Arithmetic mean] of values in cells x through y; sum(x:y) / count(x:y)
| all
|-
| count(x:y)
| [https://en.wikipedia.org/wiki/Counting Counting] of cells from x through y
| all
|-
| max(x:y)
| [https://en.wikipedia.org/wiki/Maxima_and_minima Maximum] value in cells x through y
| all
|-
| min(x:y)
| [https://en.wikipedia.org/wiki/Maxima_and_minima Minimum] value in cells x through y
| all
|-
| stddev(x:y)
| [https://en.wikipedia.org/wiki/Standard_deviation Standard deviation] of values in cells x through y
| all
|-
| sum(x: y)
| [https://en.wikipedia.org/wiki/Summation Sum] of values in cells x through y
| all
|}


== Conditional Expressions ==
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 <=.


<div class="mw-translate-fuzzy">
Formulas are written as e.g follows: 2 * Length, where Length is a property in the object holding the expression.
Bedingte Ausdrücke haben die Form ''Bedingung ? ResultatTrue : ResultatFalse''
</div>


The following [https://en.wikipedia.org/wiki/Relational_operator#Standard_relational_operators relational operators] are defined:
== Reference To CAD-Data ==
{| class="wikitable float-right mw-collapsible mw-uncollapsed"
!style="width: 33%;"|Unit
!style="width: 66%;"|Description
|-
| ==
| equal to
|-
| !=
| not equal to
|-
| >
| greater than
|-
| <
| less than
|-
| >=
| greater than or equal to
|-
| <=
| less than or equal to
|}


<div class="mw-translate-fuzzy">
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.
Die Bedingung muss ein Ausdruck sein, der entweder 0 ({{FALSE}}) oder ungleich 0 ({{TRUE}}) ergibt. Die folgenden Vergleichsoperatoren stehen zur Verfügung: ==, !=, >, <, >= und <=.
</div>


Units can directly be used in expressions. The parser connects them to the previous value. So ''''2mm'''' or ''''2 mm'''' is valid while '''' mm'''' is invalid because there is no preceding value.
The following table shows some examples:

All values must have a unit. Therefore you must in general use a unit for values in spreadsheets.<br/>
In some cases it works even without a unit, for example if you have e.g. in spreadsheet cell B1 just the number ''1.5'' and refer to it for a pad height. This only works because the pad height predefines the unit ''mm'' that is used if no unit is given. It will nevertheless fail if you use for the pad height e.g. '''Sketch1.Constraints.Width - Spreadsheet.B1''' because ''Sketch1.Constraints.Width'' has a unit and ''Spreadsheet.B1'' has not.

Units with exponents can directly be entered. So e.g. '''mm^3''' will be recognized as mm³ and '''m^3''' will be recognized as m³.

<div class="mw-translate-fuzzy">
Trigonometrische Funktionen verwenden Grad als Standardeinheit; durch Hinzufügen von '''rad''' nach dem <em>ersten</em> Wert kann auch die Einheit Radiant in einem Ausdruck verwendet werden.
Beispiel: cos(45) ist das Gleiche wie cos(pi rad / 4).
</div>

The following units are recognized by the expression parser:

Amount of substance:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 33%;"|Unit
!style="width: 66%;"|Description
|-
| mol
| [https://en.wikipedia.org/wiki/Mole_(unit) Mole]
|}

Angle:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 33%;"|Unit
!style="width: 66%;"|Description
|-
| °
| [https://en.wikipedia.org/wiki/Degree_(angle) Degree]; alternative to the unit ''deg''
|-
| deg
| [https://en.wikipedia.org/wiki/Degree_(angle) Degree]; alternative to the unit ''°''
|-
| rad
| [https://en.wikipedia.org/wiki/Radian Radian]
|-
| gon
| [https://en.wikipedia.org/wiki/Gon_(unit) Gradian]
|-
| S
| [https://en.wikipedia.org/wiki/Minute_and_second_of_arc Second of arc]
|-
| ″
| [https://en.wikipedia.org/wiki/Minute_and_second_of_arc Second of arc]; alternative to the unit ''S''
|-
| M
| [https://en.wikipedia.org/wiki/Minute_and_second_of_arc Minute of arc]
|-
| ′
| [https://en.wikipedia.org/wiki/Minute_and_second_of_arc Minute of arc]; alternative to the unit ''M''
|}

Current:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 33%;"|Unit
!style="width: 66%;"|Description
|-
| mA
| Milli[https://en.wikipedia.org/wiki/Ampere ampere]
|-
| A
| [https://en.wikipedia.org/wiki/Ampere Ampere]
|-
| kA
| Kilo[https://en.wikipedia.org/wiki/Ampere ampere]
|-
| MA
| Mega[https://en.wikipedia.org/wiki/Ampere ampere]
|}

Energy / Work:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 33%;"|Unit
!style="width: 66%;"|Description
|-
| J
| [https://en.wikipedia.org/wiki/Joule Joule]
|-
| Ws
| [https://en.wikipedia.org/wiki/Joule#Watt_second Watt second]; alternative to the unit ''Joule''
|-
| VAs
| [https://en.wikipedia.org/wiki/Joule Volt-ampere-second]; alternative to the unit ''Joule''
|-
| CV
| [https://en.wikipedia.org/wiki/Joule Coulomb·Volt]; alternative to the unit ''Joule''
|}

Force:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 33%;"|Unit
!style="width: 66%;"|Description
|-
| mN
| Milli[https://en.wikipedia.org/wiki/Newton_(unit) newton]
|-
| N
| [https://en.wikipedia.org/wiki/Newton_(unit) Newton]
|-
| kN
| Kilo[https://en.wikipedia.org/wiki/Newton_(unit) newton]
|-
| MN
| Mega[https://en.wikipedia.org/wiki/Newton_(unit) newton]
|-
| lbf
| [https://en.wikipedia.org/wiki/Pound_(force) Pound of force]
|}

Length:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 33%;"|Unit
!style="width: 66%;"|Description
|-
| nm
| Nano[https://en.wikipedia.org/wiki/Metre meter]
|-
| um
| Micro[https://en.wikipedia.org/wiki/Metre meter]; alternative to the unit ''µm''
|-
| µm
| Micro[https://en.wikipedia.org/wiki/Metre meter]; alternative to the unit ''mu''
|-
| mm
| Milli[https://en.wikipedia.org/wiki/Metre meter]
|-
| cm
| Centi[https://en.wikipedia.org/wiki/Metre meter]
|-
| mm
| Milli[https://en.wikipedia.org/wiki/Metre meter]
|-
| dm
| Deci[https://en.wikipedia.org/wiki/Metre meter]
|-
| m
| [https://en.wikipedia.org/wiki/Metre Meter]
|-
| km
| Kilo[https://en.wikipedia.org/wiki/Metre meter]
|-
| mil
| [https://en.wikipedia.org/wiki/Thousandth_of_an_inch Thousandth of an inch]; alternative to the unit ''thou''
|-
| thou
| [https://en.wikipedia.org/wiki/Thousandth_of_an_inch Thousandth of an inch]; alternative to the unit ''mil''
|-
| in
| [https://en.wikipedia.org/wiki/Inch Inch]
|-
| ft
| [https://en.wikipedia.org/wiki/Foot_(unit) Foot]; alternative to the unit '
|-
| '
| [https://en.wikipedia.org/wiki/Foot_(unit) Foot]; alternative to the unit ''ft''
|-
| yd
| [https://en.wikipedia.org/wiki/Yard Yard]
|-
| mi
| [https://en.wikipedia.org/wiki/Mile Mile]
|}

Luminous intensity:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 33%;"|Unit
!style="width: 66%;"|Description
|-
| cd
| [https://en.wikipedia.org/wiki/Candela Candela]
|}

Mass:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 33%;"|Unit
!style="width: 66%;"|Description
|-
| ug
| Micro[https://en.wikipedia.org/wiki/Gram gram]; alternative to the unit ''µg''
|-
| µg
| Micro[https://en.wikipedia.org/wiki/Gram gram]; alternative to the unit ''ug''
|-
| mg
| Milli[https://en.wikipedia.org/wiki/Gram gram]
|-
| g
| [https://en.wikipedia.org/wiki/Gram Gram]
|-
| kg
| Kilo[https://en.wikipedia.org/wiki/Gram gram]
|-
| t
| [https://en.wikipedia.org/wiki/Tonne Tonne]
|-
| oz
| [https://en.wikipedia.org/wiki/Ounce Ounce]
|-
| lb
| [https://en.wikipedia.org/wiki/Pound_(mass) Pound]; alternative to the unit ''lbm''
|-
| lbm
| [https://en.wikipedia.org/wiki/Pound_(mass) Pound]; alternative to the unit ''lb''
|-
| st
| [https://en.wikipedia.org/wiki/Stone_(weight) Stone]
|-
| cwt
| [https://en.wikipedia.org/wiki/Hundredweight Hundredweight]
|}

<div class="mw-translate-fuzzy">
=== Bedingte Ausdrücke ===
</div>

Pressure:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 33%;"|Unit
!style="width: 66%;"|Description
|-
| Pa
| [https://en.wikipedia.org/wiki/Pascal_(unit) Pascal]
|-
| kPa
| Kilo[https://en.wikipedia.org/wiki/Pascal_(unit) pascal]
|-
| MPa
| Mega[https://en.wikipedia.org/wiki/Pascal_(unit) pascal]
|-
| GPa
| Giga[https://en.wikipedia.org/wiki/Pascal_(unit) pascal]
|-
| uTorr
| Micro[https://en.wikipedia.org/wiki/Torr torr]; alternative to the unit ''µTorr''
|-
| µTorr
| Micro[https://en.wikipedia.org/wiki/Torr torr]; alternative to the unit ''uTorr''
|-
| mTorr
| Milli[https://en.wikipedia.org/wiki/Torr torr]
|-
| Torr
| [https://en.wikipedia.org/wiki/Torr Torr]
|-
| psi
| [https://en.wikipedia.org/wiki/Pounds_per_square_inch Pound-force per square inch]
|-
| ksi
| Kilo[https://en.wikipedia.org/wiki/Pounds_per_square_inch pound-force per square inch]
|}

Temperature:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 33%;"|Unit
!style="width: 66%;"|Description
|-
| uK
| Micro[https://en.wikipedia.org/wiki/Kelvin kelvin]; alternative to the unit ''µK''
|-
| µK
| Micro[https://en.wikipedia.org/wiki/Kelvin kelvin]; alternative to the unit ''uK''
|-
| mK
| Milli[https://en.wikipedia.org/wiki/Kelvin kelvin]
|-
| K
| [https://en.wikipedia.org/wiki/Kelvin Kelvin]
|}

Time:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 33%;"|Unit
!style="width: 66%;"|Description
|-
| s
| [https://en.wikipedia.org/wiki/Second Second]
|-
| min
| [https://en.wikipedia.org/wiki/Minute Minute]
|-
| h
| [https://en.wikipedia.org/wiki/Hour Hour]
|}

Torque:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 33%;"|Unit
!style="width: 66%;"|Description
|-
| Nm
| [https://en.wikipedia.org/wiki/Newton_metre Newton metre]
|}

Volume:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 33%;"|Unit
!style="width: 66%;"|Description
|-
| l
| [https://en.wikipedia.org/wiki/Litre Liter]
|}

The following commonly used units are not yet supported:
{| class="wikitable float-right mw-collapsible mw-collapsed"
!style="width: 25%;"|Unit
!style="width: 50%;"|Description
!style="width: 25%;"|Alternative
|-
| C
| [https://en.wikipedia.org/wiki/Coulomb Coulomb]
| 1 A*s
|-
| Hz
| [https://en.wikipedia.org/wiki/Hertz Hertz]
| 1 /s
|-
| V
| [https://en.wikipedia.org/wiki/Volt Volt]
| 1 W/A
|-
| eV
| [https://en.wikipedia.org/wiki/Electronvolt Electronvolt]
| 1.602176634e-19 J
|-
| kWh
| [https://en.wikipedia.org/wiki/Kilowatt_hour Kilowatt hour]
| 3.6e6 J
|-
| bar
| [https://en.wikipedia.org/wiki/Bar_(unit) Bar]
| 100 kPa
|-
| T
| [https://en.wikipedia.org/wiki/Tesla_(unit) Tesla]
| 1 kg/s^2/A
|-
| F
| [https://en.wikipedia.org/wiki/Farad Farad]
| 1 s^4*A^2/m^2/kg
|-
| H
| [https://en.wikipedia.org/wiki/Henry_(unit) Henry]
| 1 kg*m^2/s^2/A^2
|-
| u
| [https://en.wikipedia.org/wiki/Unified_atomic_mass_unit Atomic mass unit]; alternative to the unit 'Da'
| 1.66053906660e-27 kg
|-
| Da
| [https://en.wikipedia.org/wiki/Unified_atomic_mass_unit Dalton]; alternative to the unit 'u'
| 1.66053906660e-27 kg
|-
| cal
| [https://en.wikipedia.org/wiki/Calorie Calorie]
| 4.184 J
|-
| sr
| [https://en.wikipedia.org/wiki/Steradian Steradian]
| not directly
|-
| lm
| [https://en.wikipedia.org/wiki/Lumen_(unit) Lumen]
| not directly
|-
| lx
| [https://en.wikipedia.org/wiki/Lux Lux]
| not directly
|-
| Mpsi
| Mega[https://en.wikipedia.org/wiki/Pounds_per_square_inch pound-force per square inch]
| 1000 ksi
|}

== Referenzen auf CAD-Daten ==

<div class="mw-translate-fuzzy">
Größenangaben von anderen Elementen der Konstruktion können in Rechenausdrücken verwendet werden. Die Syntax für eine Referenz auf ein Eigenschaftenfeld sieht wie folgt aus: Objekt.Eigenschaft. Wenn sich die Eigenschaft aus einer Reihe von Feldern zusammensetzt, kann wie folgt darauf zugegriffen werden: Object.Eigenschaft.Feldname.
</div>

<div class="mw-translate-fuzzy">
Die folgende Tabelle zeigt einige Beispiele:
{|{{Prettytable}}
{|{{Prettytable}}
!CAD-Data
!CAD-Daten
!Aufruf im Rechenausdruck
!Call in expression
!Ergebnis
!Result
|-
|-
|Parametrische Länge eines Quaders vom Arbeitsbereich Part
|Parametric Length of a Part-Workbench Cube
|Cube.Length
|Cube.Length
|Length with units mm
|Länge mit der Einheit mm
|-
|-
|Volumen des Quaders
|Volume of the Cube
|Cube.Shape.Volume
|Cube.Shape.Volume
|Volume in mm&sup3; without units
|Volumen in mm&sup3; Ausgabe ohne Einheiten
|-
|-
|Typ des Quader-Shapess (geometrische Figur)
|Type of the Cube-shape
|Cube.Shape.ShapeType
|Cube.Shape.ShapeType
|String: Solid
|String: Solid
|-
|-
|Label of the Cube
|Label des Quader-Objekts
|Cube.Label
|Cube.Label
|String: Cube
|String: Cube
|-
|-
|x-Koordinate des Schwerpunktes des Quaders
|x-coordinate of center of mass of the Cube
|Cube.Shape.CenterOfMass.x
|Cube.Shape.CenterOfMass.x
|x-coordinate in mm without units
|x-Koordinate in mm ohne Einheiten
|-
|-
|Value of constraint in a sketch
|Wert einer Beschränkung in einer Skizze
|Constraints.Width
|Constraints.Breite
|Numerischer Wert der benannten Beschränkung 'Breite' in der Skizze
|Numeric value of the named constraint 'Width' in the sketch
|-
|-
|Wert eines Alias einer Kalkulationstabelle
|Value of a spreadsheet alias
|Spreadsheet.Depth
|Spreadsheet.Tiefe
|Value of the alias "Depth" in the spreadsheet "Spreadsheet"
|Wert des Alias "Tiefe" in der Kalkulationstabelle "Spreadsheet"
|-
|-
|Wert einer lokalen Eigenschaft des Objekts
|Value of a local property
|Length
|Length
|Value of the Length property in e.g a Pad object, if the expression is used in e.g Length2 in the same object.
|Wert der Eigenschaft Length von z. B. einem Pad-Objekt, wenn es in dem Ausdruck z. B. in der Eigenschaft Length2 im gleichen Objekt benutzt wird.
|}
|}
</div>


==Dokumentweit gültige globale Variablen==
== Document-wide global variables ==


Es gibt aktuell keine Infrastruktur für globale Variablen in FreeCAD. Stattdessen können beliebige Variablen als Zellwerte innerhalb einer Tabelle des Arbeitsbereiches [[Spreadsheet Workbench/de|Tabellenkalkulation (Spreadsheet)]] definiert werden und ihnen ein Name mittels der Alias-Eigenschaft für Zellen zugeordnet werden(Rechtsklick auf die Zelle). Danach können die Zellwerte in allen Rechenausdrücken verwendet werden, sie wie andere Eigenschaften von Objekten auch.
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|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.


==Dokumentübergreifende Verlinkung==
== Cross-document linking ==


<div class="mw-translate-fuzzy">
It's possible that you have a spreadsheet in one document and reference values from there in other documents.
Es ist möglich, eine Tabelle in einem Dokument aus einem anderen Dokument zu referenzieren.
</div>


<div class="mw-translate-fuzzy">
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.
Wichtiger Hinweis: Der Name des Dokuments muss angegeben werden, um es von einem anderen Dokument aus referenzieren zu können. Wenn ein Dokument nun zum ersten Mal gespeichert wird, muss dem Dokument ein Name gegeben werden, der normalerweise nicht "Unbenannt1" (oder eine anderssprachige Version) ist, und dann sind die Links beim erneuten Öffnen verloren. Deshalb ist es empfehlenswert zuerst das Stammdokument mit der Tabelle zu erstellen, zu speichern und zu schließen. Nach dem erneuten Öffnen wird der interne Name auf den Dateinamen gesetzt. Danach kann das Dokument geändert und gespeichert werden, aber es darf nicht umbenannt werden.
</div>


<div class="mw-translate-fuzzy">
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
Danach können weitere Dokumente erstellt werden in denen entsprechende Rechenausdrücke eingesetzt werden. Angenommen, dass das Stammdokument "Stammdaten" genannt wurde, können Referenzen auf das Stammdokument wie folgt eingesetzt werden: Stammdaten#Spreadsheet.Length
</div>


master#modelConstants.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.


Note that the master document must be loaded for the values in the master to be available to the dependent document.
Of course, it's up to you to load the corresponding documents later when you want to change anything.


<div class="mw-translate-fuzzy">
== Known issues / remaining tasks ==
Unglücklicherweise ist der eingebaute Formelprüfer mehr verwirrend als hilfreich, weil er immer wieder Interpretationsfehler meldet, dass dieses oder jenes nicht existiert. Daher einfach mit dem Eintippen fortfahren. Wenn man fertig ist und der Inhalt stimmt, dann wird plötzlich OK gemeldet.
</div>


Bei der Verwendung verknüpfter Dokumente ist der Benutzer dafür verantwortlich, dass alle Dokumente auch geöffnet sind, wenn irgendwelche Änderungen vorzunehmen sind.
* 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 [https://freecadweb.org/tracker/set_project.php?project_id=4;20 FreeCAD Bugtracker Expressions category]


==Bekannte Probleme / Verbliebene Aufgaben==

<div class="mw-translate-fuzzy">
* Der Abhängigkeitsgraph basiert auf der Beziehung zwischen Objekten des Dokuments und nicht auf Beziehungen zwischen Eigenschaften. Das bedeutet, dass man nicht Daten einem Objekt zur Verfügung stellen kann und gleichzeitig Daten von diesem Objekt abfragt, selbst wenn keine zyklische Verknüpfung auf Basis der Eigenschaften besteht. Zur Umgehung des Problems können mehrere Tabellen angelegt werden: Eine Tabelle, die die Objektdaten zur Verfügung stellt und eine andere zur Datenauswertung.
* Es gibt keinen Manager für Rechenausdrücke, mit dem alle vorhandenen Rechenausdrücke aufgelistet werden können oder sonst wie erstellt, gelöscht oder gesucht werden können.
* Offene Fehler/Tickets für die Rechenausdrücke (Expressions) können hier nachgeschlagen werden: [https://freecadweb.org/tracker/set_project.php?project_id=4;20 FreeCAD Bugtracker Expressions category]
</div>

{{Userdocnavi/de}}
[[Category:User Documentation/de]]
[[Category:User Documentation/de]]
[[Category:API/de]]


{{clear}}
{{clear}}
<languages/>

Revision as of 10:13, 13 July 2019

Funktionen mit Mehrfachargumenten: min, max, count, sum, stddev, und average. Funktionen mit Mehrfachargumenten können mit einem oder einer ganzen Reihe von Argumenten aufgerufen werden, jeweils durch ein Komma oder Semikolon getrennt. Die Argumente können Bereiche (Zwei Zellreferenzen getrennt durch einen Doppelpunkt) enthalten, z.B =average(B1:B8). Dies wird als Liste der Werte B1, B2, ... B8 ausgewertet.

eingeführt mit Version 0.16

Seit der Version 0.16 ist es möglich, Modelleigenschaften 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 File:Sketcher Expressions.png. Wenn man auf dieses Symbol klickt oder das Gleichheitszeichen (=) eingibt, öffnet sich der Formeleditor für die entsprechende Eigenschaft.

Ein Rechenausdruck in FreeCAD ist ein mathematischer Ausdruck in der üblichen Schreibweise für die Standardrechenarten (+, -, * und /) und mathematische Funktionen (siehe unten). Zusätzlich können referenzierte Eigenschaften anderer Objekte und bedingte Ausdrücke verwendet werden. Zahlen in Rechenausdrücken können mit einer optionalen Einheit versehen sein.

Numbers may use either a comma ',' or a decimal point '.' separating whole digits from decimals. When the decimal marker is used, it must be followed by at least one digit. Thus, the expressions 1.+2. and 1,+2, are invalid, but 1.0+2.0 and 1,0+2,0 are valid.

The constants pi and e are predefined, and must be written in lowercase.

Die Rechenarten und Funktionen verstehen sich auf Einheiten und erfordern deshalb bei der Verwendung von Einheiten zulässige Einheitenkombinationen. 2mm+4mm ist zum Beispiel ein zulässiger Rechenausdruck, während 2mm+4 nicht zulässig ist. (Der Grund dafür ist, das ein Ausdruck wie 1in + 4 von Menschen wohl als 1in + 4in interpretiert wird, das System dies jedoch nicht erraten kann, da alle Einheiten intern in das SI-System konvertiert werden.)

Supported Operators

The following operators are supported:

Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division
^ Exponentiation

Mehrere Argumente einer Funktion können entweder durch Semikolon (';') oder ein Komma gefolgt von einem Leerzeichen getrennt werden. Im letzteren Fall wird das Komma nach der Eingabe in ein Semikolon konvertiert. Wenn ein Semikolon verwendet wurde, ist kein nachfolgendes Leerzeichen erforderlich.

The following constants are supported:

Constant Description
e Euler's number
pi Pi

Unterstützte Funktionen

General Mathematical Functions

Die nachfolgend aufgeführten mathematischen Funktionen sind verfügbar.

Multiple arguments to a function may be separated by either a semicolon ';' or a comma followed by a space ', '. In the latter case, the comma is converted to a semicolon after entry. When a semicolon is used, no trailing space is necessary.

Trigonometric functions use degree as their default unit. For radian measure, add rad following the first value in an expression. So e.g. cos(45) is the same as cos(pi rad / 4).
These trigonometric functions are supported:

Function Description Value range
acos(x) Arc cosine -1 <= x <= 1
asin(x) Arc sine -1 <= x <= 1
atan(x) Arc tangent all
atan2(x, y) Arc tangent of x/y all, except y = 0
cos(x) Cosine all
cosh(x) Hyperbolic cosine all
sin(x) Sine all
sinh(x) Hyperbolic sine all
tan(x) Tangent all, except of x = n·90 with n = integer
tanh(x) Hyperbolic tangent all

These functions for exponentiation and logarithmization are supported:

Function Description Value range
exp(x) Exponential function all
log(x) Natural logarithm x > 0
log10(x) Common logarithm x > 0
pow(x, y) Exponentiation all
sqrt(x) Square root x >= 0

These functions for rounding, truncation and remainder are supported:

Function Description Value range
abs(x) Absolute value all
ceil(x) Ceiling function smallest integer value greater than or equal to x all
floor(x) Floor function, largest integer value less than or equal to x all
mod(x, y) Remainder after dividing x by y all, except y = 0
round(x) Rounding to the nearest integer all
trunc(x) Truncation to the nearest integer all

Die Konstanten pi und e sind vordefiniert.

These aggregate functions are supported:

Function Description Value range
average(x:y) Arithmetic mean of values in cells x through y; sum(x:y) / count(x:y) all
count(x:y) Counting of cells from x through y all
max(x:y) Maximum value in cells x through y all
min(x:y) Minimum value in cells x through y all
stddev(x:y) Standard deviation of values in cells x through y all
sum(x: y) Sum of values in cells x through y all

Conditional Expressions

Bedingte Ausdrücke haben die Form Bedingung ? ResultatTrue : ResultatFalse

The following relational operators are defined:

Unit Description
== equal to
!= not equal to
> greater than
< less than
>= greater than or equal to
<= less than or equal to

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

Units can directly be used in expressions. The parser connects them to the previous value. So '2mm' or '2 mm' is valid while ' mm' is invalid because there is no preceding value.

All values must have a unit. Therefore you must in general use a unit for values in spreadsheets.
In some cases it works even without a unit, for example if you have e.g. in spreadsheet cell B1 just the number 1.5 and refer to it for a pad height. This only works because the pad height predefines the unit mm that is used if no unit is given. It will nevertheless fail if you use for the pad height e.g. Sketch1.Constraints.Width - Spreadsheet.B1 because Sketch1.Constraints.Width has a unit and Spreadsheet.B1 has not.

Units with exponents can directly be entered. So e.g. mm^3 will be recognized as mm³ and m^3 will be recognized as m³.

Trigonometrische Funktionen verwenden Grad als Standardeinheit; durch Hinzufügen von rad nach dem ersten Wert kann auch die Einheit Radiant in einem Ausdruck verwendet werden. Beispiel: cos(45) ist das Gleiche wie cos(pi rad / 4).

The following units are recognized by the expression parser:

Amount of substance:

Unit Description
mol Mole

Angle:

Unit Description
° Degree; alternative to the unit deg
deg Degree; alternative to the unit °
rad Radian
gon Gradian
S Second of arc
Second of arc; alternative to the unit S
M Minute of arc
Minute of arc; alternative to the unit M

Current:

Unit Description
mA Milliampere
A Ampere
kA Kiloampere
MA Megaampere

Energy / Work:

Unit Description
J Joule
Ws Watt second; alternative to the unit Joule
VAs Volt-ampere-second; alternative to the unit Joule
CV Coulomb·Volt; alternative to the unit Joule

Force:

Unit Description
mN Millinewton
N Newton
kN Kilonewton
MN Meganewton
lbf Pound of force

Length:

Unit Description
nm Nanometer
um Micrometer; alternative to the unit µm
µm Micrometer; alternative to the unit mu
mm Millimeter
cm Centimeter
mm Millimeter
dm Decimeter
m Meter
km Kilometer
mil Thousandth of an inch; alternative to the unit thou
thou Thousandth of an inch; alternative to the unit mil
in Inch
ft Foot; alternative to the unit '
' Foot; alternative to the unit ft
yd Yard
mi Mile

Luminous intensity:

Unit Description
cd Candela

Mass:

Unit Description
ug Microgram; alternative to the unit µg
µg Microgram; alternative to the unit ug
mg Milligram
g Gram
kg Kilogram
t Tonne
oz Ounce
lb Pound; alternative to the unit lbm
lbm Pound; alternative to the unit lb
st Stone
cwt Hundredweight

Bedingte Ausdrücke

Pressure:

Unit Description
Pa Pascal
kPa Kilopascal
MPa Megapascal
GPa Gigapascal
uTorr Microtorr; alternative to the unit µTorr
µTorr Microtorr; alternative to the unit uTorr
mTorr Millitorr
Torr Torr
psi Pound-force per square inch
ksi Kilopound-force per square inch

Temperature:

Unit Description
uK Microkelvin; alternative to the unit µK
µK Microkelvin; alternative to the unit uK
mK Millikelvin
K Kelvin

Time:

Unit Description
s Second
min Minute
h Hour

Torque:

Unit Description
Nm Newton metre

Volume:

Unit Description
l Liter

The following commonly used units are not yet supported:

Unit Description Alternative
C Coulomb 1 A*s
Hz Hertz 1 /s
V Volt 1 W/A
eV Electronvolt 1.602176634e-19 J
kWh Kilowatt hour 3.6e6 J
bar Bar 100 kPa
T Tesla 1 kg/s^2/A
F Farad 1 s^4*A^2/m^2/kg
H Henry 1 kg*m^2/s^2/A^2
u Atomic mass unit; alternative to the unit 'Da' 1.66053906660e-27 kg
Da Dalton; alternative to the unit 'u' 1.66053906660e-27 kg
cal Calorie 4.184 J
sr Steradian not directly
lm Lumen not directly
lx Lux not directly
Mpsi Megapound-force per square inch 1000 ksi

Referenzen auf CAD-Daten

Größenangaben von anderen Elementen der Konstruktion können in Rechenausdrücken verwendet werden. Die Syntax für eine Referenz auf ein Eigenschaftenfeld sieht wie folgt aus: Objekt.Eigenschaft. Wenn sich die Eigenschaft aus einer Reihe von Feldern zusammensetzt, kann wie folgt darauf zugegriffen werden: Object.Eigenschaft.Feldname.

Die folgende Tabelle zeigt einige Beispiele:

CAD-Daten Aufruf im Rechenausdruck Ergebnis
Parametrische Länge eines Quaders vom Arbeitsbereich Part Cube.Length Länge mit der Einheit mm
Volumen des Quaders Cube.Shape.Volume Volumen in mm³ Ausgabe ohne Einheiten
Typ des Quader-Shapess (geometrische Figur) Cube.Shape.ShapeType String: Solid
Label des Quader-Objekts Cube.Label String: Cube
x-Koordinate des Schwerpunktes des Quaders Cube.Shape.CenterOfMass.x x-Koordinate in mm ohne Einheiten
Wert einer Beschränkung in einer Skizze Constraints.Breite Numerischer Wert der benannten Beschränkung 'Breite' in der Skizze
Wert eines Alias einer Kalkulationstabelle Spreadsheet.Tiefe Wert des Alias "Tiefe" in der Kalkulationstabelle "Spreadsheet"
Wert einer lokalen Eigenschaft des Objekts Length Wert der Eigenschaft Length von z. B. einem Pad-Objekt, wenn es in dem Ausdruck z. B. in der Eigenschaft Length2 im gleichen Objekt benutzt wird.

Dokumentweit gültige globale Variablen

Es gibt aktuell keine Infrastruktur für globale Variablen in FreeCAD. Stattdessen können beliebige Variablen als Zellwerte innerhalb einer Tabelle des Arbeitsbereiches Tabellenkalkulation (Spreadsheet) definiert werden und ihnen ein Name mittels der Alias-Eigenschaft für Zellen zugeordnet werden(Rechtsklick auf die Zelle). Danach können die Zellwerte in allen Rechenausdrücken verwendet werden, sie wie andere Eigenschaften von Objekten auch.

Dokumentübergreifende Verlinkung

Es ist möglich, eine Tabelle in einem Dokument aus einem anderen Dokument zu referenzieren.

Wichtiger Hinweis: Der Name des Dokuments muss angegeben werden, um es von einem anderen Dokument aus referenzieren zu können. Wenn ein Dokument nun zum ersten Mal gespeichert wird, muss dem Dokument ein Name gegeben werden, der normalerweise nicht "Unbenannt1" (oder eine anderssprachige Version) ist, und dann sind die Links beim erneuten Öffnen verloren. Deshalb ist es empfehlenswert zuerst das Stammdokument mit der Tabelle zu erstellen, zu speichern und zu schließen. Nach dem erneuten Öffnen wird der interne Name auf den Dateinamen gesetzt. Danach kann das Dokument geändert und gespeichert werden, aber es darf nicht umbenannt werden.

Danach können weitere Dokumente erstellt werden in denen entsprechende Rechenausdrücke eingesetzt werden. Angenommen, dass das Stammdokument "Stammdaten" genannt wurde, können Referenzen auf das Stammdokument wie folgt eingesetzt werden: Stammdaten#Spreadsheet.Length

    master#modelConstants.Length  

Note that the master document must be loaded for the values in the master to be available to the dependent document.

Unglücklicherweise ist der eingebaute Formelprüfer mehr verwirrend als hilfreich, weil er immer wieder Interpretationsfehler meldet, dass dieses oder jenes nicht existiert. Daher einfach mit dem Eintippen fortfahren. Wenn man fertig ist und der Inhalt stimmt, dann wird plötzlich OK gemeldet.

Bei der Verwendung verknüpfter Dokumente ist der Benutzer dafür verantwortlich, dass alle Dokumente auch geöffnet sind, wenn irgendwelche Änderungen vorzunehmen sind.

Bekannte Probleme / Verbliebene Aufgaben

  • Der Abhängigkeitsgraph basiert auf der Beziehung zwischen Objekten des Dokuments und nicht auf Beziehungen zwischen Eigenschaften. Das bedeutet, dass man nicht Daten einem Objekt zur Verfügung stellen kann und gleichzeitig Daten von diesem Objekt abfragt, selbst wenn keine zyklische Verknüpfung auf Basis der Eigenschaften besteht. Zur Umgehung des Problems können mehrere Tabellen angelegt werden: Eine Tabelle, die die Objektdaten zur Verfügung stellt und eine andere zur Datenauswertung.
  • Es gibt keinen Manager für Rechenausdrücke, mit dem alle vorhandenen Rechenausdrücke aufgelistet werden können oder sonst wie erstellt, gelöscht oder gesucht werden können.
  • Offene Fehler/Tickets für die Rechenausdrücke (Expressions) können hier nachgeschlagen werden: FreeCAD Bugtracker Expressions category