* Sketch Dimension: `name = value` defines a user parameter (#2916) In a dimension's value (the D tool's box, and `sketch.dimension`'s `value` from scripts, the CLI, MCP and the control channel), `name = expression` adds the user parameter `name` with that expression and dimensions with `name`: typing `width = 40` on a line gives a 40 mm user parameter `width` and a dimension whose expression is `width`. A bare number is read in the design's unit, as a bare dimension value is; an angle's parameter is in degrees. The expression may be anything the parameter editor takes. It is one command: one undo removes the parameter and the dimension together, and a dimension the sketch refuses leaves no parameter behind. A taken name is refused with a hint (type the name to use it, or change it in Parameters), a reserved name with the parameter editor's message, and a left side that is not a name (`2 = 3`) still fails to parse as before. A driven dimension defines nothing. The reply carries `defined`, and the status line names the parameter. The splitter lives in the doc crate (`expr::definition`) so other value inputs can take the same form later; editing an existing dimension, the inline shape boxes and feature dialogs are follow-ups. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Sketch Dimension: say why a name is refused, in the command's own words (#2916) The dimension editor showed a refused definition raw, in the box and the status line: "invalid parameters for `sketch.dimension`: value: `mm` is a unit, constant or function name". It now reads "Sketch Dimension: `mm` is a unit name, so it cannot be a parameter name": the editor passes the command's errors through `friendly_error` like every other command, and drops the `value:` field tag, since the box is the value. The taken-name hint reads the same way: "Sketch Dimension: there is already a parameter `w`: type `w` to use it, or change it in Parameters". A reserved name says what kind of word it is and what that means (`param_name_problem`, shared with the Parameters dialog): a unit name, a function name, or a constant, "so it cannot be a parameter name"; `expr::reserved_kind` tells them apart. `friendly_error` translates the command label with the interface language (the engine's sentence stays English), so the prefix reads "Wymiar szkicu:" in Polish. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Sketch Dimension test: keep the third line off the ribbon (#2916) On current `main` the ribbon floats over the top of the canvas, and the test's third line at sketch y = 50 projected under it: the click opened Parameters instead of picking the line. The line now goes below the first one. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: bherbruck <brennen.herbruck@gmail.com>
3.9 KiB
Parameters and expressions
Every dimension and feature input is a model parameter (d1, d2, …). User parameters
are ones you add yourself, with a unit, an expression and an optional comment. Change them in
Change Parameters (parameters.change). The timeline rebuilds from the first feature that
uses them.
When creating or editing a sketch dimension, its value editor shows its model parameter
name (d1, d2, …). Click another driving dimension to use its name: when the value is
just a number (such as 10 or 10 mm) the name replaces it; otherwise it goes in at the
cursor, replacing selected text and keeping what you typed, so typing 10 + and clicking
d1 gives 10 + d1. Add arithmetic such as / 2 to build a dependent dimension. Press Enter to apply
the expression or Escape to cancel the edit. When placing a new dimension, width = 40 adds
the user parameter width with that value (a bare number is in the design's units) and
dimensions with it; a name that is already taken is refused.
Add and edit user parameters through the existing Change Parameters command.
In the MANAGE tab's PARAMETERS section, click Parameters to open the user and model parameter editor. The Configurations button in CONFIGURATIONS opens the configuration table; Configure remains in the dropdown for configuring columns.
Press Enter in the new parameter's name, expression or comment field to add it. Valid entries return focus to the name field for the next parameter; invalid entries remain editable. In expression fields, type a parameter or dimension name for autocomplete, or press Ctrl+Space to open suggestions, including in an empty field. Up/Down selects an autocomplete suggestion, Enter/Tab accepts it, and Escape dismisses the suggestions. Accepting a suggestion does not also submit the parameter.
Expressions are unit-aware: 2 * width + 5 mm, angle / 2, sqrt(area), 1 in + 3 mm, using
+ - * / ^, parentheses, sin cos tan asin acos atan atan2 sqrt abs min max floor ceil round mod trunc and unit conversion. A decimal comma works too, outside parentheses: 2,5 mm is
2.5 mm (inside a function's parentheses the comma separates its arguments, so write
max(2.5, 3) there). A mixed number is one value, as imperial sizes are written: 2 1/8" and
3 7/16 in are 2.125 in and 3.4375 in (a whole number, a space, then a proper fraction of whole
numbers). A length where an angle is expected (or the other way round) is an
error, not a silent conversion. Cycles are reported with their path (a → b → a), renaming a
parameter updates every expression, dimension and feature input that uses it, and a parameter
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
typed into a feature is read. In an inch design 2 means 2 in. The Box, Cylinder, Sphere, Torus
and Coil dialogs start with their sizes in the design's units, unit shown (20 mm, 20 in).
Changing the units never moves existing geometry. A size worked out from a bare number keeps
the unit the number was given in: a sphere with a bare diameter of 20 has the radius
(20 mm) / 2 in a millimetre design. Beside a unit-less expression such as 2 * 5 or a
unit-less parameter, which is read in the design's units, the number stays bare and is read
with it.
Parameters export to and import from CSV or JSON (parameters.export, parameters.import).
Configurations (config.*) keep a table of rows, each with its own parameter values and
suppressed features, physical materials and body appearances, switched with config.activate.
The table's Library picker selects material or appearance values. Choose Follow material
to clear an appearance override. Custom looks retain their colour and opacity across
activation, undo and save/reopen. See
configuration commands and examples.