Unit Converter: one length in every unit, read from and applied to the selection

Object › Plug-ins › Unit Converter › Unit Converter Panel opens a panel
with one number field per unit of Preferences › Units › East Asian Type
(pt, picas, in, mm, cm, px, ft & in, m, yd, ft, Q, Ha). A length typed in
any field, with units and arithmetic as every number field reads them,
updates the others as it is typed; text that does not read leaves them as
they were. From Selection reads the selection's width and height as the
Transform panel measures them, and Width or Height picks which one the
fields show; the size read is dropped when the document, its selection,
Use Preview Bounds or Measure Type by Glyph Bounds changes. Apply sets
that side through object.setBounds as the Transform panel's W or H field
does (its reference point, Constrain Width and Height Proportions and
Transform Object Only, Pattern Only or Both), as one undo step, and adds
none when the size is already that length. Each field's copy button
copies its value, with its unit when Copy with Units is on, and is named
with its unit for screen readers.

- addon.units.convert {value, unit?} gives a length in every unit, and
  addon.units.selectionSize {} gives the selection's width and height the
  same way. Neither changes the document. convert reads at most 1024
  bytes and 128 + - * / signs.
- The decimal comma rule of the number fields moves from ui-egui to
  vectorcraft_doc::decimal_point, so the command reads "0,5 mm" as the
  fields do.
- The Transform panel's pattern switches are built by
  with_pattern_switches, which run_transform and Apply share.

Closes #5528, as proposed by @ruchirguitar.
This commit is contained in:
dotCooCoo
2026-11-14 13:02:57 -08:00
parent 14f12130e7
commit 907a759710
45 changed files with 1080 additions and 26 deletions
+39
View File
@@ -11855,6 +11855,45 @@ Path Options' Preview does (#5360).
{"name":"run_command","arguments":{"command":"addon.type.releasePath","params":{"mode":"path","keepOriginal":true}}}
```
## Unit Converter add-on
Unit Converter is a built-in add-on that shows one length in every unit at once (#5528): its commands are
`addon.units.convert` and `addon.units.selectionSize`, and in the desktop app it lives in Object › Plug-ins › Unit
Converter and in its panel (`window.panel {panel: "unitConverter"}`). Neither command changes the document.
`addon.units.convert {value, unit?}` reads `value` as a number field reads it: a number, or text with a unit suffix and
`+ - * /` arithmetic (`"10mm"`, `"1in/2"`, `"2p6"`, `"1080/2 px"`, `"3cm*50%"`, `"13q"`), a decimal comma read as a point
(`"0,5 mm"`) and a single number with a thousands comma (`"1,000 mm"`) refused, in at most 1024 bytes with at most 128 `+ - * /` signs. A
number without a suffix is in `unit` (a unit's name, suffix or key: `points`, `picas`, `inches`, `millimeters`,
`centimeters`, `pixels`, `feetInches`, `meters`, `yards`, `feet`, `q`, `ha`; default `points`); a suffix in the text
takes precedence over `unit`. It works without an open document. The command fails when `value` is missing, does not
read, or is not finite in every unit, and when `unit` is not a unit. Result: `{points, units: [{unit, label, number,
text}]}`: the length in points, then one row per unit of Preferences › Units › East Asian Type (pt, picas, in, mm, cm,
px, ft & in, m, yd, ft, Q, Ha) in that order, with the unit's key, its label, the number without its suffix and the
text with it, rounded as the number fields round them (3 decimals in pt, px, picas, Q and Ha, 4 in the others). Pixels
are points.
`addon.units.selectionSize {}` gives the selection's width and height as the Transform panel shows them: the bounding
box (rotated with rotated objects), the visual bounds with Use Preview Bounds, or the box around the selected anchor
points with Direct Selection. It fails with nothing selected. Result: `{width, height}`, each as
`addon.units.convert` gives a length.
The panel has one field per unit. A value typed in any field updates the others as it is typed, and text that does not
read leaves them as they were. Each field's copy button puts its value on the clipboard, with the unit when Copy with
Units is on. From Selection reads the selection's size (`addon.units.selectionSize`), and Width or Height picks which
of the two the fields show; the size read is dropped when the document, its selection, Use Preview Bounds or Measure
Type by Glyph Bounds changes, and the fields keep the length they show. Apply sets that side of the selection to the length with `object.setBounds`, as the Transform
panel's W or H field does: from its reference point (a symbol instance's registration point with Use Registration Point
for Symbol on), with the other side scaled too under Constrain Width and Height Proportions, and with the panel menu's
Transform Object Only, Transform Pattern Only or Transform Both. It is one undo step, and none when the size is already
that length.
```json
{"name":"run_command","arguments":{"command":"addon.units.convert","params":{"value":"10mm"}}}
{"name":"run_command","arguments":{"command":"addon.units.convert","params":{"value":2.5,"unit":"in"}}}
{"name":"run_command","arguments":{"command":"addon.units.selectionSize","params":{}}}
```
## Save location errors
A save refused by the filesystem with PermissionDenied or ReadOnlyFilesystem returns
+4
View File
@@ -2297,6 +2297,10 @@ A VectorCraft addition, not a feature of the reference app, so no area score mov
A VectorCraft addition, not a feature of the reference app (it has no command for this), so no area score moves. Object › Plug-ins › Type Tools › Release Type on a Path… splits each selected type on a path into point type holding the same text and the plain path it was set on, or keeps only one of them (#5532). The path keeps its exact shape (open or closed, anchors and handles, the object's transform), layer and place in the stacking order, with no fill and no stroke since type paths carry no paint of their own. The text keeps its runs, character and paragraph attributes and becomes point type on one straight line whose baseline starts where the first character sat on the path; Type on a Path Options don't apply to point type and are dropped. Keep Original leaves the type on a path and adds the released objects above it. Other objects are left alone and a selection with no type on a path makes no undo step; otherwise the run is one undo step, the released objects are selected, and the dialog's Preview works as Type on a Path Options' does (#5360). Tests: `cmd::addons::typetools::tests::release` in `vectorcraft-engine` (each mode, Keep Original, mixed and empty selections, closed, open, curved and flipped paths, transformed and grouped type, multi-style and unicode text with a centred paragraph, empty type, undo and redo, preview, cancel and commit, bad params refused), `release_type_on_a_path_previews_cancels_and_runs_on_ok` in `vectorcraft-ui-egui` and `command_sweep`. Commands: `docs/mcp.md` › Type Tools add-on › Release Type on a Path.
## Unit Converter add-on (2026-11-14)
A VectorCraft addition, so no area score moves. Object › Plug-ins › Unit Converter opens a panel with one number field per unit of Preferences › Units › East Asian Type (pt, picas, in, mm, cm, px, ft & in, m, yd, ft, Q, Ha), as proposed in #5528. A length typed in any field, with units and arithmetic as every number field reads them, updates the others as it is typed; text that does not read leaves them as they were. From Selection reads the selection's width and height as the Transform panel measures them, Width or Height picks which one the fields show, and Apply sets that side of the selection through `object.setBounds` as the Transform panel's W or H field does (its reference point, Constrain Width and Height Proportions and its Transform Object Only, Pattern Only or Both choice) as one undo step, with no step when the size is already that length. Each field's copy button copies its value, with its unit when Copy with Units is on. Agents use `addon.units.convert` and `addon.units.selectionSize`, which change nothing in the document (`docs/mcp.md`). Tests: `cmd::addons::units::tests` in `vectorcraft-engine` (every unit, number-field syntax, preview bounds and selected anchors, bad params and unknown keys refused), `addons::units::tests` in `vectorcraft-ui-egui` (typing, From Selection and a changed selection, Apply with the Transform panel's reference point, proportions, pattern choice and a symbol's registration point, copy, screen-reader names) and `command_sweep`.
## Cutting Tools add-on: Stencil Bridges (2026-11-12)
A VectorCraft addition, so no area score moves. Object › Plug-ins › Cutting Tools › Stencil Bridges… cuts strips of a set width (0.01 to 1000 pt, 2 by default) out of the selected art so that a stencil cut from it keeps its islands, such as the inside of an O or a hole in a shape, attached to the sheet ([stencil islands and bridges](https://en.wikipedia.org/wiki/Stencil)). Every island is joined to the sheet, directly or through another island, by the shortest crossings that fit, then gets more bridges spread around it up to the count asked for (1 to 16); bridges run vertically, horizontally or along the shortest crossing among 12 directions 15° apart. The art is measured by the area its outlines enclose (hidden objects left out), type by its glyph outlines without converting the type, and becomes one compound path with the gaps cut; the selected objects that make up the art go to a new hidden layer, Stencil Original, or are replaced, and selected objects with no outlines stay where they are. Art with no islands is left as it is with a message and no undo step, islands the cut result still encloses are counted and reported, and the run is one undo step. Tests: `addons::stencil::tests` in `vectorcraft-pathops` (an O, two holes, nested islands, curved outlines, width, direction, the shortest crossing at an angle, more bridges per island and their spacing, narrow islands, slivers, outlines that touch at a corner, the curve tolerance, open outlines, limits and the work budget), `cmd::addons::cutting::stencil::tests` in `vectorcraft-engine` (the hidden layer and undo, replacing, width with units, type, hidden group members, objects with no outlines, the result's paint, kind and place in the stacking order, no islands, narrow islands, bad params refused), `stencil_bridges_opens_its_dialog_and_runs_on_ok` in `vectorcraft-ui-egui` and `command_sweep`. Commands: `docs/mcp.md` › Cutting Tools add-on › Stencil Bridges.