Units and Expressions#
Overview#
Every value in Fusion has a unit type: length, angle, or unitless. Expressions are evaluated with dimensional analysis: you can add lengths to lengths, multiply a length by a number, and divide a length by a length to get a unitless ratio. You cannot add a length to an angle.
Understanding this removes most "mysterious" red fields.
Where to find it#
- Document units: in the Browser, expand the design node and the Document Settings entry; set Units (mm, cm, m, in, ft). This sets the default unit for bare numbers in length fields (Autodesk's API documentation states that a bare number is read in the document's default units, while a unit typed in the expression overrides it).
- Parameter units: the Unit column or dropdown in Change Parameters.
- Any numeric field: type an expression with explicit units, such as
1.5 inor25.4 mm.
Step by step#
Mix units safely#
- In a length field, type
1 in + 5 mm. Fusion evaluates to 30.4 mm (in a mm document). - In an angle field, type
45 degor0.785 rad. - For unitless numbers (counts, ratios) choose "No Unit" for the parameter.
Bare numbers#
A bare number in a length field takes the document's default unit. If your document is in mm, 10 means 10 mm. In a user parameter, a bare number is read in the document default unit according to the API documentation, and the parameter's unit is the unit of the result; if these differ (an inch parameter in a mm document), test with 4 and check the Value column before relying on it. To avoid surprises, always type units in important expressions.
Convert units#
- Create a parameter
length_inwith unitinand expression4. - Create
length_mmwith unitmmand expressionlength_in. The value displays as 101.6 mm.
Fusion converts automatically. If the parameter's unit and the expression's dimension disagree (angle versus length), you get an error.
Use ratios#
ratio(no unit) =box_l / box_w.diag(mm) =sqrt((box_l / 1 mm) ^ 2 + (box_w / 1 mm) ^ 2) * 1 mm. Autodesk's reference sayssqrttakes a unitless argument and returns a unitless value, so strip the units first and restore them afterwards.
Trigonometry#
- Functions take angles;
sin(30 deg)gives 0.5. - Always write
degorradexplicitly inside trig functions rather than relying on a default for a bare number (not specified in the parameters reference). - Inverse functions (
asin,acos,atan) return angles.
Options reference#
| Item | Syntax | Notes |
|---|---|---|
| Add / subtract | a + b, a - b | Same dimension required |
| Multiply / divide | a * b, a / b | Any dimensions; result units combine |
| Power | a ^ n | Check dimensions; also pow(a; n) (first argument any unit, second unitless; the result is unit^n) |
| Parentheses | ( ) | Standard precedence |
| Square root | sqrt(x) | Unitless in, unitless out; domain non-negative |
| Trig | sin, cos, tan (angle in, unitless out); asin, acos, atan (unitless in, angle out) | Write deg or rad explicitly |
| Hyperbolic | sinh, cosh, tanh (angle in); asinh, acosh, atanh (angle out) | Rare in CAD |
| Rounding | round, ceil, floor | Unitless in and out; round rounds .5 away from zero (round(-1.5) is -2), floor(-1.5) is -2, ceil(-1.5) is -1 |
| Sign and modulo | sign(x), a % b | sign returns 0 if negative, 1 if positive (per the reference); % is floating-point modulo |
| Comparison | >, <, >=, <=, ==, <> | Used inside if |
| Logic | if(cond; a; b), and, or, not | if takes three arguments and can be nested |
| Random | random() | Changes on recompute; avoid in dimensions |
| Min / max / abs | min(a; b), max(a; b), abs(x) | Any type per the reference; use like units in practice. Multi-argument functions use a semicolon as the delimiter |
| Logs/exp | log, ln, exp | Unitless arguments |
| Constants | PI, E, Gravity (980.665 cm/s^2), SpeedOfLight (29,979,245,800 cm/s) | PI and E are unitless; Autodesk writes PI in capitals |
| Length units | mm, cm, m, hm, micron, in, ft, yd, mi, nauticalMile, mil | Full list in Autodesk's Unit types page |
| Angle units | deg, rad, grad | Write the unit explicitly |
The function list above follows Autodesk's Parameters reference. Do not use a comma between arguments, because it conflicts with the decimal delimiter in some locales. If a function is not accepted, Fusion flags the expression in red.
Order of operations, highest first: parentheses, exponentiation, negation, multiplication and division, addition and subtraction. Because negation ranks below exponentiation in that list, -2 ^ 2 evaluates as -(2^2) = -4; write (-2) ^ 2 when you mean 4.
Tips and pitfalls#
Tip: When an expression is red, break it into two parameters and inspect the Value of each. The first one that goes red or shows wrong units is the culprit.
Tip: Write
* 1 mmto turn a unitless count into a length when needed (for examplen * 1 mm). Use sparingly.
Tip: To get a unitless number from a length, divide by
1 mmin the same expression:box_l / 1 mm.
Warning: Changing document units does not change the stored geometry (internally cm), but bare-number fields reinterpret. A bare
25in an inch document means 25 inches. Retype with units when copying between designs.
Warning: Imperial fractions:
1/4 inis a division and should work. A mixed number such as1 1/4 incontains a space and may not parse as intended, so write(1 + 1/4) * 1 inor1.25 in. I could not confirm this edge case in Autodesk's help, so test it.
Warning: Integer division is not an issue (values are floating point), but rounding display precision hides small differences. Increase the displayed precision (Document Settings has a Precision setting) if you need to inspect.
Unit conventions to adopt:
- Keep document units equal to your manufacturing units (mm for metric work).
- Store thread sizes, counts, and ratios as No Unit parameters.
- Put units in every literal inside expressions (
2 mm,45 deg), so nothing depends on settings. - Name angle parameters with an
_aor_angsuffix, and length parameters in a consistent way.
Precision and tolerances#
Display precision is a setting; the stored values are full double-precision. For fits, represent tolerance explicitly: shaft_d = 10 mm, hole_d = shaft_d + 0.1 mm.
Worked calculations with dimensional analysis#
Each of these shows how the unit of the result is determined, so you can predict it before pressing Enter.
| Expression | Operands | Result | Why |
|---|---|---|---|
10 mm * 3 | length, number | 30 mm | Number scales the length |
10 mm * 3 mm | length, length | 30 mm^2 | Product is an area; not valid for a length parameter |
30 mm / 10 mm | length, length | 3 (no unit) | Ratio |
1 in + 5 mm | length, length | 30.4 mm in a mm document | Converted automatically |
45 deg + 30 mm | angle, length | Error | Dimensions differ |
n * 1 mm | number, length | n mm | Common way to turn a count into a length |
box_l / 1 mm | length, length | number | Strips the unit |
(box_l - 2 * wall) / (n - 1) | length, number | length | Pitch of n holes |
if(wall > 3 mm; 2 mm; 1 mm) | condition, lengths | length | Comparison operators work between like units |
A particular trap is a parameter whose unit is set to mm while the expression has an area (a * b): the dialog flags it because the dimensions disagree. Set the parameter's unit to match the dimension of the expression, or change the expression.
Use if for switching#
Autodesk's reference lists if, and, or and not. A minimum wall check is if(wall < 1.2 mm; 1.2 mm; wall), equivalent to max(wall; 1.2 mm). A condition on a count: if(n > 8; 8; n). Use if when the alternative is not a simple min or max, for example a different boss diameter for steel versus plastic. Nested if handles three cases: if(n < 4; 3 mm; if(n < 8; 4 mm; 5 mm)).
Worked example: a hole row#
For box_l = 80 mm, margin = 6 mm and n = 5 holes:
hole_pitch = (box_l - 2 * margin) / (n - 1)gives (80 - 12) / 4 = 17 mm.- Hole x-positions: 6, 23, 40, 57 and 74 mm.
- If
nbecomes 1 the denominator is zero. Guard it with(box_l - 2 * margin) / max(n - 1; 1)so a single hole stays at the margin instead of failing.
Unit conventions across a team#
| Practice | Why |
|---|---|
| Set document units to match manufacturing units | Bare numbers mean what you expect |
| Put units on every literal in an expression | Result does not depend on a setting |
| Store counts and ratios as No Unit | Avoids * 1 mm hacks |
Name angle parameters with _ang | They are visibly not lengths |
Keep tolerance in its own parameter (tol = 0.1 mm) | One edit changes all fits |
| Prefer deg in angle fields | Stored internally in radians; deg is what you read |
Display precision#
Displayed values are rounded for readability but stored at full precision. A hole_pitch that reads 17 mm might be 17.0000001. When comparing values in an if, round first. round takes a unitless argument, so strip the unit: round(hole_pitch / 1 mm * 100) / 100. If a comparison such as == fails unexpectedly, display precision is almost certainly the cause. Rounding functions accept and return unitless values only.
Failure modes and fixes#
| Symptom | Cause | Fix |
|---|---|---|
| Expression red | Dimension mismatch | Split into steps and inspect each Value |
| Result 25.4 times off | Inch value entered in a mm document, or vice versa | Type units explicitly |
min(a, b) rejected | Comma used as argument delimiter | Use a semicolon: min(a; b) |
| Angle result is tiny | Bare number treated as radians | Write deg |
| Divide by zero error | n - 1 with n = 1 | Guard with max(n - 1; 1) |
if returns the wrong branch | Condition compares different units | Convert both sides to the same unit |
| Parameter unit conflicts | Parameter set to Text or No Unit, expression has units | Change the parameter's unit |
Practice exercise#
- Set document units to mm. Create
d_in(in) =0.5,d_mm(mm) =d_in. Confirm 12.7 mm. - Create
circ(mm) =PI * d_mm. Check ~39.9 mm. - Create
tilt(deg) =atan(10 mm / 40 mm). Check ~14.04 deg. - Create
bad=d_mm + tiltand read the error. - Create
box_l,margin(mm) andn(no unit), thenhole_pitch=(box_l - 2 * margin) / (n - 1)with a unitlessnand confirm the unit is mm.
Expected result: you can predict the unit and value of any expression before pressing Enter.
Related#
- User parameters and equations
- The Change Parameters dialog
- Design-for-change patterns