parameters.add: a parameter with no unit takes the design's units (#8865) (#8880)

* claim: #8865

* parameters.add: a parameter with no unit takes the design's units (#8865)

A new parameter given no unit took "mm" for any length or bare number, so
in an inch design `parameters.add {name: v, expression: "40/2"}` made a
20 mm parameter where the Parameters dialog makes 20 in. The unit a new
parameter infers is now a length in the design's units (mm designs are
unchanged); parameters.change on a new name and parameters.import share
the same inference. Angles and unit-less values keep their units.

A definition typed into a value of no fixed kind (a coupling's pitch,
a joint's value) still reads its bare number as millimetres, as that
field does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
HiroKenEz
2026-10-29 18:18:04 +00:00
committed by GitHub
parent 9416e975e0
commit c857f2fe70
7 changed files with 96 additions and 10 deletions
+3 -1
View File
@@ -75,7 +75,9 @@ in use can't be deleted (the error lists its users).
The design's units (Document Settings in the browser: mm, cm, m, in or ft) set how a bare number
or unitless arithmetic expression typed into a length field is read. In an inch design `0.25`
and `1 / 4` mean 0.25 in. Operation dialogs start with lengths in the design's units, including
and `1 / 4` mean 0.25 in. A new user parameter given no unit (`parameters.add` or
`parameters.import` without `unit`) is a length in the design's units, as the Parameters dialog
makes it: `40/2` is 20 in. Operation dialogs start with lengths in the design's units, including
secondary distances, wall thicknesses, gaps, offsets and radii. Canvas handles and live sketch
values use the same units as the operation. Angles, counts and scale factors keep their own
units. Preferences selects the default units for new designs; existing designs use their own