Fusion Guide
intermediate9 min read

Units and Expressions

How Fusion evaluates units, operators and functions in parameter expressions, and how to avoid unit mismatch errors.

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 in or 25.4 mm.

Step by step#

Mix units safely#

  1. In a length field, type 1 in + 5 mm. Fusion evaluates to 30.4 mm (in a mm document).
  2. In an angle field, type 45 deg or 0.785 rad.
  3. 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#

  1. Create a parameter length_in with unit in and expression 4.
  2. Create length_mm with unit mm and expression length_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#

  1. ratio (no unit) = box_l / box_w.
  2. diag (mm) = sqrt((box_l / 1 mm) ^ 2 + (box_w / 1 mm) ^ 2) * 1 mm. Autodesk's reference says sqrt takes a unitless argument and returns a unitless value, so strip the units first and restore them afterwards.

Trigonometry#

  1. Functions take angles; sin(30 deg) gives 0.5.
  2. Always write deg or rad explicitly inside trig functions rather than relying on a default for a bare number (not specified in the parameters reference).
  3. Inverse functions (asin, acos, atan) return angles.

Options reference#

ItemSyntaxNotes
Add / subtracta + b, a - bSame dimension required
Multiply / dividea * b, a / bAny dimensions; result units combine
Powera ^ nCheck dimensions; also pow(a; n) (first argument any unit, second unitless; the result is unit^n)
Parentheses( )Standard precedence
Square rootsqrt(x)Unitless in, unitless out; domain non-negative
Trigsin, cos, tan (angle in, unitless out); asin, acos, atan (unitless in, angle out)Write deg or rad explicitly
Hyperbolicsinh, cosh, tanh (angle in); asinh, acosh, atanh (angle out)Rare in CAD
Roundinground, ceil, floorUnitless 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 modulosign(x), a % bsign returns 0 if negative, 1 if positive (per the reference); % is floating-point modulo
Comparison>, <, >=, <=, ==, <>Used inside if
Logicif(cond; a; b), and, or, notif takes three arguments and can be nested
Randomrandom()Changes on recompute; avoid in dimensions
Min / max / absmin(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/explog, ln, expUnitless arguments
ConstantsPI, 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 unitsmm, cm, m, hm, micron, in, ft, yd, mi, nauticalMile, milFull list in Autodesk's Unit types page
Angle unitsdeg, rad, gradWrite 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 mm to turn a unitless count into a length when needed (for example n * 1 mm). Use sparingly.

Tip: To get a unitless number from a length, divide by 1 mm in 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 25 in an inch document means 25 inches. Retype with units when copying between designs.

Warning: Imperial fractions: 1/4 in is a division and should work. A mixed number such as 1 1/4 in contains a space and may not parse as intended, so write (1 + 1/4) * 1 in or 1.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 _a or _ang suffix, 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.

ExpressionOperandsResultWhy
10 mm * 3length, number30 mmNumber scales the length
10 mm * 3 mmlength, length30 mm^2Product is an area; not valid for a length parameter
30 mm / 10 mmlength, length3 (no unit)Ratio
1 in + 5 mmlength, length30.4 mm in a mm documentConverted automatically
45 deg + 30 mmangle, lengthErrorDimensions differ
n * 1 mmnumber, lengthn mmCommon way to turn a count into a length
box_l / 1 mmlength, lengthnumberStrips the unit
(box_l - 2 * wall) / (n - 1)length, numberlengthPitch of n holes
if(wall > 3 mm; 2 mm; 1 mm)condition, lengthslengthComparison 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 n becomes 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#

PracticeWhy
Set document units to match manufacturing unitsBare numbers mean what you expect
Put units on every literal in an expressionResult does not depend on a setting
Store counts and ratios as No UnitAvoids * 1 mm hacks
Name angle parameters with _angThey are visibly not lengths
Keep tolerance in its own parameter (tol = 0.1 mm)One edit changes all fits
Prefer deg in angle fieldsStored 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#

SymptomCauseFix
Expression redDimension mismatchSplit into steps and inspect each Value
Result 25.4 times offInch value entered in a mm document, or vice versaType units explicitly
min(a, b) rejectedComma used as argument delimiterUse a semicolon: min(a; b)
Angle result is tinyBare number treated as radiansWrite deg
Divide by zero errorn - 1 with n = 1Guard with max(n - 1; 1)
if returns the wrong branchCondition compares different unitsConvert both sides to the same unit
Parameter unit conflictsParameter set to Text or No Unit, expression has unitsChange the parameter's unit

Practice exercise#

  1. Set document units to mm. Create d_in (in) = 0.5, d_mm (mm) = d_in. Confirm 12.7 mm.
  2. Create circ (mm) = PI * d_mm. Check ~39.9 mm.
  3. Create tilt (deg) = atan(10 mm / 40 mm). Check ~14.04 deg.
  4. Create bad = d_mm + tilt and read the error.
  5. Create box_l, margin (mm) and n (no unit), then hole_pitch = (box_l - 2 * margin) / (n - 1) with a unitless n and confirm the unit is mm.

Expected result: you can predict the unit and value of any expression before pressing Enter.

  • User parameters and equations
  • The Change Parameters dialog
  • Design-for-change patterns

Sources

Checked against these Autodesk help topics (opens autodesk.com):

Related pages