Vlastnosti lze definovat pomocí matematických výrazů. V grafickém uživatelském rozhraní se u rolovacích polí nebo vstupních polí, která jsou vázána na vlastnosti, po aktivaci zobrazí modrá ikona . Kliknutím na ikonu nebo zadáním znaménka rovnosti = se otevře editor výrazů pro danou vlastnost. Pokud se ve vstupním poli místo ikony zobrazuje tlačítko ..., lze editor výrazů otevřít kliknutím pravým tlačítkem myši na vlastnost a výběrem položky Výraz z kontextového menu.
Výraz ve FreeCADu je matematický výraz využívající standardní matematické operátory, funkce a předdefinované konstanty, jak je popsáno níže. Kromě toho může výraz odkazovat na vlastnosti objektů a také používat podmínky. Čísla ve výrazu mohou mít připojenou volitelnou jednotku.
Čísla mohou k oddělení celých číslic od desetinných míst používat buď čárku , nebo desetinnou tečku .. Pokud se používá desetinná čárka, musí za ní následovat alespoň jedna číslice. Výrazy 1. + 2. a 1, + 2, jsou tedy neplatné, ale 1.0 + 2.0 a 1,0 + 2,0 jsou platné.
Operátory a funkce zohledňují jednotky a vyžadují platné kombinace jednotek, jsou-li zadány. Například 2mm + 4mm je platný výraz, zatímco 2mm + 4 platný není. To platí také pro odkazy na vlastnosti objektů, které mají jednotky, jako jsou vlastnosti délky. Proto je Pad001.Length + 1 neplatné, protože přidává čisté číslo k vlastnosti s jednotkami délky; je třeba použít Pad001.Length + 1mm.
Některé chyby související s jednotkami mohou působit neintuitivně, protože výrazy jsou buď odmítnuty, nebo vedou k výsledkům, které neodpovídají jednotkám nastavované vlastnosti. Zde je několik příkladů:
1/2mm se nevykládá jako půl milimetru, ale jako 1/(2mm), což vede k výsledku: 0.5 mm^-1.
sqrt(2)mm není platné, protože volání funkce není číslo. Je třeba zadat sqrt(2) * 1mm.
Více argumentů funkce lze oddělit buď středníkem ;, nebo čárkou následovanou mezerou , . V druhém případě se čárka po zadání převede na středník. Při použití středníku není nutné zadávat mezeru na konci.
Argumenty mohou obsahovat odkazy na buňky v tabulce. Odkaz na buňku se skládá z velkého písmene označujícího řádek, za kterým následuje číslo sloupce, například A1. Na buňku lze odkazovat také pomocí jejího aliasu, například Spreadsheet.MyPartWidth.
Jak již bylo uvedeno výše, na objekt můžete odkazovat pomocí jeho ÚdajeNázvu. Můžete však použít i jeho ÚdajeNávěstí. V případě ÚdajeNávěstí musí být tento údaj uzavřen mezi dvojité znaky << a >>, například <<Label>>.
Můžete odkazovat na jakoukoli vlastnost objektu. Chcete-li například odkazovat na výšku válce, můžete použít Cylinder.Height nebo <<Label_of_cylinder>>.Height.
K objektům lze přidávat uživatelské vlastnosti a používat je ve výrazech. Pro odkazování na vazby ve skicách se doporučuje jim přiřadit názvy.
Další informace o odkazování na objekty najdete v článku Odkaz na CAD data.
Jsou podporovány následující konstanty:
| Konstanta | Popis |
|---|---|
| e | Eulerovo číslo |
| pi | Pi |
Jsou podporovány následující operátory:
| Operátor | Popis |
|---|---|
| + | Sčítání |
| - | Odčítání |
| * | Násobení |
| / | https://en.wikipedia.org/wiki/Division_(mathematics) Dělení] s plovoucí desetinnou čárkou |
| % | Zbytek po dělení |
| ^ | Umocňování |
| == | Rovnost |
| != | Nerovnost |
| > | Větší než |
| >= | Větší než nebo rovno |
| < | Menší než |
| <= | Menší než nebo rovno |
Jsou podporovány následující matematické funkce:
Trigonometric functions use degree as their default unit. For radians add rad following the first value in an expression. So e.g. cos(45) is the same as cos(pi rad / 4). Expressions in degrees can use either deg or °, e.g. 360deg - atan2(3; 4) or 360° - atan2(3; 4). If an expression is without units and needs to be converted to degrees or radians for compatibility, multiply by 1deg, 1° or 1rad as appropriate, e.g. (360 - X) * 1deg; (360 - X) * 1°; (0.5 + pi / 2) * 1rad.
| Function | Description | Input range |
|---|---|---|
acos(x)
|
Arc cosine | -1 <= x <= 1 |
asin(x)
|
Arc sine | -1 <= x <= 1 |
atan(x)
|
Arc tangent, return value in the range -90° < value < 90° | all |
atan2(y; x)
|
Arc tangent of y/x accounting for quadrant, return value in the range -180° < value <= 180° | all, the invalid input x = y = 0 returns 0 |
cos(x)
|
Cosine | all |
cosh(x)
|
Hyperbolic cosine | all |
sin(x)
|
Sine | all |
sinh(x)
|
Hyperbolic sine | all |
tan(x)
|
Tangent | all, except x = n*90 with n = odd integer |
tanh(x)
|
Hyperbolic tangent | all |
hypot(x; y)
|
Pythagorean addition (hypotenuse), e.g. hypot(4; 3) = 5 | x and y >= 0 |
cath(x; y)
|
Given hypotenuse, and one side, returns other side of triangle, e.g. cath(5; 3) = 4 | x >= y >= 0 |
| Function | Description | Input 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 |
cbrt(x) introduced in 0.21
|
Cubic root | all |
| Function | Description | Input 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, sign of result is that of the dividend | all, except y = 0 |
round(x)
|
Rounding to the nearest integer | all |
trunc(x)
|
Truncation to the nearest integer in the direction of zero | all |
| Function | Description | Input range |
|---|---|---|
and(a; b; c; ...)
|
AND: 1 if abs of all arguments is greater than or equal to 1e-7, else 0 | all |
or(a; b; c; ...)
|
OR: 0 if abs of all arguments is less than 1e-7, else 1 | all |
not(a)
|
Negation: 1 if abs(a) is less than 1e-7 else 0 | all |
Aggregate functions take one or more arguments.
Individual arguments to aggregate functions may consist of ranges of cells. A range of cells is expressed as two cell references separated by a colon :, for example average(B1:B8) or sum(A1:A4; B1:B4).
The cell references may also use cell aliases, for example average(StartTemp:EndTemp).
The following aggregate functions are supported:
| Function | Description | Input range |
|---|---|---|
average(a; b; c; ...)
|
Average value of the arguments, same as sum(a; b; c; ...) / count(a; b; c; ...) | all |
count(a; b; c; ...)
|
Count of the arguments, typically used for cell ranges | all |
max(a; b; c; ...)
|
Maximum value of the arguments | all |
min(a; b; c; ...)
|
Minimum value of the arguments | all |
stddev(a; b; c; ...)
|
Standard deviation of the values of the arguments | all |
sum(a; b; c; ...)
|
Sum of the values of the arguments, typically used for cell ranges | all |
Strings are identified in expressions by surrounding them with opening/closing double chevrons (as are labels).
In following example, "TEXT" is recognized as a string : <<TEXT>>
Strings can be concatenated using the '+' sign.
Following example <<MY>> + <<TEXT>> will be concatenated to "MYTEXT".
Číselné hodnoty lze převést na řetězce pomocí funkce str:
str(Box.Length.Value)
String formatting is supported using the (old) %-style Python way.
All %-specifiers as defined in Python documentation.
As an example, supposing you have a default 10mm-side cube named 'Box' (default FreeCAD naming), the following expression <<Cube length : %s>> % Box.Length will expand to "Cube length : 10.0 mm"
For more than one %-specifier use the following syntax: <<Cube length is %s and width is %s>> % tuple(Box.Length; Box.Width). Or use concatenation: <<Cube length is %s>> % Box.Length + << and width is %s>> % Box.Width. Both will expand to "Cube length is 10.0 mm and width is 10.0 mm".
Ukázkový soubor FreeCADu využívající formátování řetězců je k dispozici na fóru
The following objects may be created in expressions using the following functions:
| Type | Function | Description |
|---|---|---|
Tuple
|
tuple(a; b; ...)
|
Example: tuple(2; 1; 2)
|
List
|
list(a; b; ...)
|
Example: list(2; 1; 2)
|
Vector
|
vector(x; y; z)
|
Create a vector using three unit-less or Length unit values.
Example: |
create(<<vector>>; x; y; z)
| ||
Matrix
|
matrix( a11; a12; a13; a14; a21; a22; a23; a24; a31; a32; a33; a34; a41; a42; a43; a44 ) |
Create a 4x4 matrix in row-major order:
A minimum of 1 argument can be supplied such as Example: |
create(<<matrix>>; a11; a12; ...; a44)
| ||
Rotation
|
rotation(axis; angle)
|
Create a Rotation by specifying its axis (Vector) and angle (Angle unit or unit-less), or three Euler angles α, β, γ.
Examples:
|
rotation(α; β; γ)
| ||
create(<<rotation>>; axis; angle)
| ||
create(<<rotation>>; α; β; γ)
| ||
Placement
|
placement(base; rotation)
|
Create a Placement with various parameters, including:
Examples:
|
placement(base; rotation; center)
| ||
placement(base; axis; angle)
| ||
placement(matrix)
| ||
create(<<placement>>; ...)
|
Funkce: introduced in 1.0.
| Function / Operator | Description |
|---|---|
v1 + v2
|
Add two vectors. |
v1 - v2
|
Subtract two vectors. |
v * s
|
Uniformly scale a vector by s.
|
vangle(v1; v2)
|
Angle between two vectors in degrees. |
vcross(v1; v2)
|
Cross product of two vectors . |
v1 * v2
|
Dot product of two vectors . |
vdot(v1; v2)
| |
vlinedist(v1; v2; v3)
|
Distance between vector v1 and a line through v2 in direction v3.
|
vlinesegdist(v1; v2; v3)
|
Distance between vector v1 and the closest point on a line segment from v2 to v3.
|
vlineproj(v1; v2; v3)
|
Project vector v1 on a line through v2 in direction v3.
|
vnormalize(v)
|
Normalize a vector to a unit vector. |
vplanedist(v1)
|
Distance between vector v1 and a plane defined by a point v2 and a normal v3.
|
vplaneproj(v1)
|
Project vector v1 on a plane defined by a point v2 and a normal v3.
|
vscale(v; sx; sy; sz)
|
Non-uniformly scale a vector by sx in the X direction, sy in the Y direction, and sz in the Z direction.
|
vscalex(v; sx)
| |
vscaley(v; sy)
| |
vscalez(v; sz)
|
Rotation and Placement can each be represented by a Matrix. The following functions all take in a Matrix, Rotation, or Placement as their first parameter denoted in the table below by m. The type of the returned object is the same as the object supplied in the first argument except when using mtranslate on a Rotation, in which case a Placement will be returned.
| Function | Description |
|---|---|
minvert(m)
|
Calculate the Inverse matrix. |
mrotate(m; rotation)
|
Rotate by either:
|
mrotate(m; axis; angle)
| |
mrotate(m; α; β; γ)
| |
mrotatex(m; angle)
|
Rotate around the X axis. |
mrotatey(m; angle)
|
Rotate around the Y axis. |
mrotatez(m; angle)
|
Rotate around the Z axis. |
mtranslate(m; vector)
|
Translate by a vector (Vector) or X, Y, Z values. If a Rotation is translated, the returned object is a Placement.
|
mtranslate(m; x; y; z)
| |
mscale(m; vector)
|
Scale by a vector (Vector) or X, Y, Z values.
|
mscale(m; x; y; z)
|
Podmíněné výrazy mají tvar podmínka ? výsledek_pravda : výsledek_nepravda. Podmínka je definována jako výraz, jehož výsledkem je buď 0 (nepravda), nebo hodnota odlišná od nuly (pravda). Upozorňujeme, že jakákoli hodnota je vyhodnocena jako nula, pokud platí abs(hodnota) < 1e-7; v opačném případě je vyhodnocena jako hodnota odlišná od nuly.
Dostupné relační operátory najdete v sekci Podporované operátory.
VarSet.MyBool == 1 ? 10 mm : 15 mm.VarSet.MyBool ? 10 mm : 15 mm.
Units can be used directly 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³.
If you have a variable whose name is that of a unit you must put the variable between << >> to prevent it from being recognized as a unit. For example if you have the dimension Sketch.Constraints.A it would be recognized as the unit ampere. Therefore you must write it in the expression as Sketch.Constraints.<<A>>.
The following units are recognized by the expression parser:
| Unit | Description |
|---|---|
| ° | Degree; alternative to the unit deg |
| deg | Degree; alternative to the unit ° |
| rad | Radian |
| gon | Gradian |
| M | Minute of arc; alternative to the unit ′ |
| ′ | Minute of arc; this is the prime symbol (U+2032); alternative to the unit M |
| S | Second of arc; DOES NOT WORK; alternative to the unit ″ |
| ″ | Second of arc; this is the double prime symbol (U+2033); alternative to the unit S |
| Unit | Description |
|---|---|
| pF | Picofarad |
| nF | Nanofarad |
| uF | Microfarad; alternative to the unit µF |
| µF | Microfarad; alternative to the unit uF |
| mF | Millifarad |
| F | Farad; 1 F = 1 s^4·A^2/m^2/kg |
| Unit | Description |
|---|---|
| C | Coulomb; 1 C = 1 A*s |
| Unit | Description |
|---|---|
| uS | Microsiemens; alternative to the unit µS |
| µS | Microsiemens; alternative to the unit uS |
| mS | Millisiemens |
| S | Siemens; 1 S = 1 s^3·A^2/kg/m^2 |
| kS | KiloSiemens |
| MS | MegaSiemens |
| Unit | Description |
|---|---|
| nH | Nanohenry |
| uH | Microhenry; alternative to the unit µH |
| µH | Microhenry; alternative to the unit uH |
| mH | Millihenry |
| H | Henry; 1 H = 1 kg·m^2/s^2/A^2 |
| Unit | Description |
|---|---|
| mJ | Millijoule |
| J | Joule |
| kJ | Kilojoule |
| eV | Electronvolt; 1 eV = 1.602176634e-19 J |
| keV | Kiloelectronvolt |
| MeV | Megaelectronvolt |
| kWh | Kilowatt hour; 1 kWh = 3.6e6 J |
| 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 |
| cal | Calorie; 1 cal = 4.184 J |
| kcal | Kilocalorie |
| Unit | Description |
|---|---|
| mN | Millinewton |
| N | Newton |
| kN | Kilonewton |
| MN | Meganewton |
| lbf | Pound of force |
| Unit | Description |
|---|---|
| nm | Nanometer |
| um | Micrometer; alternative to the unit µm |
| µm | Micrometer; alternative to the unit um |
| mm | Millimeter |
| cm | Centimeter |
| 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; alternative to the unit " |
| " | Inch; alternative to the unit in |
| ft | Foot; alternative to the unit ' |
| ' | Foot; alternative to the unit ft |
| yd | Yard |
| mi | Mile |
| Unit | Description |
|---|---|
| cd | Candela |
| Unit | Description |
|---|---|
| Wb | Weber; 1 Wb = 1 kg*m^2/s^2/A |
| 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 |
| 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; 1 Torr = 133.32 Pa |
| psi | Pound-force per square inch; 1 psi = 6.895 kPa |
| ksi | Kilopound-force per square inch |
| Unit | Description |
|---|---|
| uK | Microkelvin; alternative to the unit µK |
| µK | Microkelvin; alternative to the unit uK |
| mK | Millikelvin |
| K | Kelvin |
| Unit | Description |
|---|---|
| s | Second |
| min | Minute |
| h | Hour |
| Hz (1/s) | Hertz |
| kHz | Kilohertz, |
| MHz | Megahertz |
| GHz | Gigahertz |
| THz | Terahertz |
| Unit | Description |
|---|---|
| mph | Miles per hour |
| sqft | Square foot |
Následující běžně používané jednotky zatím nejsou podporovány; u některých z nich je k dispozici alternativa:
| Unit | Description | Alternative |
|---|---|---|
| °C | Celsius | [°C] + 273.15 K |
| °F | Fahrenheit; | ([°F] + 459.67) × 5/9 |
| u | Atomic mass unit; alternative to the unit Da | 1.66053906660e-27 kg |
| Da | Dalton; alternative to the unit u | 1.66053906660e-27 kg |
| sr | Steradian | not directly |
| lm | Lumen | not directly |
| lx | Lux | not directly |
| px | Pixel | not directly |
Funkce výrazů je velmi výkonná, ale aby mohla tento výkon plně využít, má určitá omezení týkající se některých znaků. K překonání tohoto omezení nabízí FreeCAD možnost používat popisky a odkazovat na ně namísto názvů objektů. V popiscích lze použít téměř všechny speciální znaky.
In cases where you cannot use a label, such as the name of a sketch's constraints, you must be aware what characters are not allowed.
U popisků neexistují žádné neplatné znaky, některé znaky je však třeba escapovat:
| Znaky | Popis |
|---|---|
', \, "
|
Je třeba ho escapovat přidáním \ před něho.
|
Například na štítek Sketch\002 je třeba odkazovat jako <<Sketch\\002>>.
Názvy objektů, jako jsou kóty, náčrtky atd., nesmí obsahovat níže uvedené znaky nebo sekvence znaků, jinak je název neplatný:
| Znaky / Sekvence znaků | Popis |
|---|---|
| +, -, *, /, ^, _, <, >, (, ), {, }, [, ], ., ,, = | Znaky, které jsou matematickými operátory nebo součástí matematických výrazů |
| A, kA, mA, MA, J, K, ' , ft , °, a mnoho dalších! | Znaky a sekvence znaků, které jsou jednotkami (viz odstavec Jednotky) |
| #, !, ?, §, $, %, &, :, ;, \, |, ~, ∆, ¿, a mnoho dalších! | Znaky používané jako zástupné znaky nebo ke spuštění speciálních operací |
| pi, e | Matematické konstanty |
| ´, `, ' , " | Znaky používané pro diakritiku |
| mezera | Mezery označují konec názvu, a proto je nelze použít |
Například následující název je platný: <<Sketch>>.Constraints.T2üßµ@. Naproti tomu tyto názvy jsou neplatné: <<Sketch>>.Constraints.test\result_2 (\r znamená "návrat vozíku") nebo <<Sketch>>.Constraints.mol (mol je jednotka).
Vzhledem k tomu, že kratší názvy (zejména pokud mají pouze jeden nebo dva znaky) mohou snadno vést k neplatným názvům, zvažte použití delších názvů a/nebo zavedení vhodných pravidel pro pojmenovávání.
Viz Spreadsheet Nastavení alias.
Ve výrazu je možné použít data přímo z modelu. Chcete-li odkazovat na vlastnost, použijte object_name.property nebo <<object_label>>.property; označení musí být uzavřena v značkách << a >>. Pokud chcete použít popisky, musí být jedinečné.
Ve všech následujících příkladech se na objekt odkazuje podle jeho názvu, ale ve všech případech lze použít i popisek objektu.
If the property is a compound of fields, the individual fields can be accessed as object_name.property.field.
To reference list objects use object_name.list[list_index]. If you want to reference a constraint in a sketch, use Sketch.Constraints[16]. If you are in the same sketch you may omit its name and just use Constraints[16]. Note that the index starts with 0, therefore Constraint17 has to be referenced as Constraints[16].
Enumeration properties in expressions will return an index: Pad.Type. To get the associated text value an additional step is required: Pad.Type.Enum[Pad.Type].
To reference the object itself use the _self pseudo property: object_name._self.
The following table shows some more examples:
| CAD data | Call in expression | Result |
|---|---|---|
| Length of a Part Box | Box.Length
|
Length with units (mm) |
| Volume of the Box | Box.Shape.Volume
|
Volume in mm³ without units |
| Shape type of the Box | Box.Shape.ShapeType
|
String: Solid |
| Label of the Box | Box.Label
|
String: Label |
| X-coordinate of center of mass of the Box | Box.Shape.CenterOfMass.x
|
X-coordinate in mm without units |
| X-coordinate of the Box placement | Box.Placement.Base.x
|
X-coordinate with units (mm) |
| X-component of the rotation axis of the Box placement | Box.Placement.Rotation.Axis.x
|
X-component of the unit vector in mm without units |
| Rotation angle of the Box placement | Box.Placement.Rotation.Angle
|
Rotation angle with units (deg) |
| Full Box object | Box._self
|
Object of type <Part::PartFeature> |
| Value of constraint in a sketch | Constraints.Width
|
Numeric value of the named constraint Width in the sketch, if the expression is used in the sketch itself.
|
| Value of constraint in a sketch | MySketch.Constraints.Width
|
Numeric value of the named constraint Width in the sketch, if the expression is used outside of the sketch.
|
| Value of a spreadsheet alias | Spreadsheet.Depth
|
Value of the alias Depth in the spreadsheet Spreadsheet
|
| Value of a local property | Length
|
Value of the ÚdajeLength property in e.g a Pad object, if the expression is used in e.g ÚdajeLength2 in the same object. |
FreeCAD checks dependencies based on the relationship between document objects, not properties. This means that you cannot provide data to an object and query that same object for results. For example, even though there are no cyclic dependencies when the properties themselves are considered, you may not have an object which gets its dimensions from a spreadsheet and then display the volume of that object in the same spreadsheet. You have to use two spreadsheets, one to drive your model and the other for reporting.
As a workaround it is possible to display a cell range from the second spreadsheet in the first (or vice versa) by creating a cell binding with the Hide dependency of binding option.
Another way to workaround cyclic dependencies is to hide the reference by using the href or hiddenref function for individual expressions, for example: href(Box.Length).
Please note that both mentioned workarounds should be used with caution, and that they do not work if the properties that are reported depend on dimensions that are driven from the same spreadsheet.
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.
It is possible (with limitations) to define a Property of an object in your current document (".FCstd" file) by using an Expression to reference a Property of an object contained in a different document (".FCstd" file). For example, a cell in a spreadsheet or the ÚdajeLength of a Part Cube, etc. in one document can be defined by an Expression that references the X Placement value or another Property of an object contained in a different document.
A document's name is used to reference it from other documents. When saving a document the first time, you choose a file name; this is usually different from the initial default "Unnamed1" (or its translated equivalent). To prevent links being lost when the master document is renamed upon saving, it is recommended that you first create the master document, create a spreadsheet inside it, and save it. Subsequently, you can still make changes to the file and its spreadsheet but you should not rename it.
Once the master document with the spreadsheet is created and saved (named), it is safe to create dependent documents. For example, assuming you name the master document master, the spreadsheet modelConstants, and give a cell an alias-name Length, you can then access the value as:
master#modelConstants.Length
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.
import FreeCAD as App
doc = App.ActiveDocument
box = doc.addObject("Part::Box", "Box")
cyl = doc.addObject("Part::Cylinder", "Cylinder")
cyl_name = cyl.Name
box.setExpression("Height", f"{cyl_name}.Height / 2")
box.setExpression("Length", f"{cyl_name}.Radius * 2")
box.setExpression("Width", "Length")
doc.recompute()
# Expressions are stored in the ExpressionEngine property:
for prop, exp in box.ExpressionEngine:
val = getattr(box, prop)
print(f"Property: '{prop}' -- Expression: '{exp}' -- Current value: {val}")