Skip to content

Model bodies: their extents seen on a plane, for a drawing view's size (#5866) - #7610

Closed
CamWight wants to merge 4 commits into
tangency-labs:drawingsfrom
CamWight:model-extents-5866
Closed

CamWight wants to merge 4 commits into
tangency-labs:drawingsfrom
CamWight:model-extents-5866

Conversation

@CamWight

@CamWight CamWight commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Part of #5866 (W07, the drawing-view command), into drawings: P2, the one model measurement a drawing view needs: a body's extents seen on a plane. drawing.view.snapshot (#5867) and saved views measure with it.

Changes a default: no

It adds a measurement; nothing a user sees changes.

What it does

  • ModelBody::mesh_bounds_in(plane): the box of a body's mesh in the plane's own coordinates (Plane::to_local), beside mesh_bounds and worked out the same way.
  • A body meshed already is measured from its own mesh. A placement of a part is measured from its definition's shared mesh, with the placement folded into the plane's two axes once (two dot products a point), so no moved copy of the mesh is made.

Tests

  • a 100 × 50 × 20 mm block seen on the three principal pairs of axes and from an isometric corner (150/√2 by 190/√6, worked by hand), and on a plane away from the origin;
  • every placement in the shared-mesh test against its moved mesh, still without a moved copy, and the same again from its own mesh once it is meshed.

Planted faults: 3, all caught, then a clean run: a placement's move skipped on a plane, its turn skipped, and x and y swapped. They ran with drawing.view.snapshot's faults (19 of 19 in all), on the same code before it moved onto the in-file drawing model.

Validation

Integration status

Based on drawings ebafe07, on #3891 (K4', the drawing commands on the design's own drawings), which is on #7490 (K3b, drawings saved inside the design's file). Until those land, this PR's diff shows them too; its own commit is the last one.

Others nearby, checked on 2026-10-27: open PRs on main change crates/doc/src/placed_mesh.rs too (#4839, #6465, #7276, and jyviko's kernel drafts #4012 and #7403). This commit only adds a function beside mesh_bounds and a test; it changes no line those PRs change, as far as their diffs show.

Refs #5866, #860

CamWight and others added 4 commits October 27, 2026 04:30
…#3890)

K3b of the drawing storage plan, after tangency-labs#7098: a drawing lives in the file of the design it draws
(bherbruck's proposal, Cameron's choice), so the separate drawing file goes.

- `Document.drawings`: the design's drawings, each its own record of the drawing family
  (`solidcraft-drawing/N`), each behind its own `Arc`. Every reader and writer of a design now
  carries them: save, Save As, autosave and recovery, crash copies, the CLI.
- A design container keeps each drawing in its own entry, `drawings/<id>.json` (Deflate), beside
  `document.json`, which holds nothing of them: its bytes, and the model cache keyed to them, are
  the same with drawings or without. A plain JSON design keeps them inline under `drawings`.
- Each drawing is read by its own family's rules, taken out of the design's JSON before the design's
  own checks. One a build can't read (a newer number, a change it doesn't know, damage) refuses the
  whole design, never dropped. So does an entry under `drawings/` that isn't a drawing's, one whose
  record has another id, drawings inline in a container's `document.json`, two drawings with one
  id, or more than 1,000 (counted before any is read). A design is never saved with two drawings of
  one id.
- Drawings are listed by name, then id: no stored order, nothing to merge when two people add
  drawings.
- A drawing has an `id`, unique among its design's drawings (`Drawing::new` takes the ids already
  taken). Its source is the design it is in: at most one, an id and no path.
- One pending design change, `drawings`: the last release refuses a design saved with it, so it
  never opens one and saves it without its drawings. One pending drawing change, `in-design`, for
  the record's new shape.
- Gone: `read_drawing`, `read_drawing_file`, `write_drawing_container`, `file_kind`, `FileKind`,
  `DRAWING_EXT` and `is_drawing_path`. `read_document`, `read_design` and the container writer are
  as they were before tangency-labs#7098, with the drawings added.

Tests: a design's drawings round-trip through both forms byte for byte, with `document.json` and
`container.json` the same with drawings or without; their order; every refusal above; a drawing's
properties kept as other tools wrote them while a sheet's number out of range is refused; the
drawing's id among its objects', a new drawing's id none of the design's; a design with two
drawings of one id not saved; mutation fuzz of a design with drawings in both forms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ndo (tangency-labs#3890)

K4' of the drawing storage plan, on K3b (a drawing lives in its design's file): make, list, open,
close and delete a design's drawings, and read and change the open one's settings and properties.
It replaces tangency-labs#3891's drawing sessions, which held a drawing as a file of its own.

- `drawing.create {name?, language?, units?}` adds a drawing of the design (one ISO A3 landscape
  sheet with the ISO border, the design its one source) and opens it; refused on an empty design.
  `drawing.list`, `drawing.open {drawing}`, `drawing.close`, `drawing.delete {drawing}`.
  `drawing.inspect`, `drawing.set`, `drawing.properties`, `.properties.set`, `.properties.remove`
  work on the open drawing. Labels in en, ja and zh.
- The open drawing is the session's (`Session::open_drawing`, kept in checkpoints), and the part
  gate keeps the parts apart: a command says the part it works on, the model unless it says
  otherwise (`.in_drawing()`, `.any_part()`). While a drawing is open the model's commands wait
  ("a drawing is open: close it to change the model"); the drawing's run only while one is.
  Files, recovery, undo and redo, checkpoints, selection, diagnostics, the command list and
  choosing a drawing work either way. `CommandSpec::allowed` is the one check running a command,
  running it inside another and listing it make.
- `Session::drawing` and `Session::edit_drawing` are the open drawing's one way in: an edit is kept
  when it changed something and still keeps the record's rules, in a new design whose other
  drawings are shared.
- A change that only touches drawings evaluates nothing: `Document::differs_only_in_drawings`
  joins the render-only path, as render settings and part properties do. A model edit shares
  every drawing, so it pays nothing for the check.
- Undo per part: a step records the part it changed (`Snapshot::part`: a drawing, or the model
  and its list of drawings). Undo and redo go through the open part's steps only. A drawing's
  step puts back only that drawing; the model's step puts back the design as it was, keeping each
  drawing it had as it is now. Making and deleting a drawing are the model's steps. A new step
  ends what could be redone in its own part only. `Snapshot::of` is the one place a step is
  taken.
- An agent's message that changed several parts keeps their steps apart, rather than merging them
  into one step that would undo only one part.
- `cmd::metadata`'s rules for reading, setting and removing properties are written once
  (`reading`, `setting`, `removing`) and used by the design's and the drawing's commands.
- `drawing::sort` is the one place the drawings' order (by name, then id) is kept;
  `Document::put_drawing` adds or replaces one in that order.

Tests: making, listing, opening, closing and deleting; what making one refuses, at the cap too; the
gate both ways, inside another command and in the command list; drawing edits as undo steps that
evaluate nothing over 100 rounds; undo and redo per part with model and drawing steps interleaved;
redo ended per part; the order by name, then id, after renames; delete and its undo; refused
changes; checkpoints; save and open in both forms; properties; hostile values for every command
that runs with a drawing open, from the registry; a fuzz of the steps in any order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
drawing.open now joins doc.open in the suggestion for `file.open`, as the rule says: both end in
the same word. The engine's and the CLI's tests check that doc.open comes first and let other
close ids follow, as the `solid.extrud` line beside them already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tangency-labs#5866)

ModelBody::mesh_bounds_in(plane) is the box of a body's mesh in a plane's own coordinates
(Plane::to_local), beside mesh_bounds and in the same way: a body meshed already is measured from
its own mesh, and a placement of a part from its definition's shared mesh, with the placement
folded into the plane's two axes once (two dot products a point), so no moved copy is made. W07's drawing.view measures a view's extents with it.

Tests: a 100 x 50 x 20 block seen on the three principal pairs of axes and from an isometric
corner (150/sqrt(2) by 190/sqrt(6), worked by hand), a plane away from the origin, and every
placement in the shared-mesh test against its moved mesh, still without a moved copy, and the
same again from its own mesh once it is meshed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:doc timeline, components, parameters, naming area:infra CI, tooling, repo, docs area:io import/export and file formats (STEP, IGES, 3MF, glTF, designs) area:ui desktop/web front end, dialogs, viewport labels Oct 27, 2026
@CamWight
CamWight marked this pull request as ready for review October 27, 2026 20:40
@CamWight

Copy link
Copy Markdown
Contributor Author

Closing: all of this PR's changes are in drawings now. They went in with #8959 (squash commit a09c24e), which carried this PR's commits. Thank you!

@CamWight CamWight closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:doc timeline, components, parameters, naming area:infra CI, tooling, repo, docs area:io import/export and file formats (STEP, IGES, 3MF, glTF, designs) area:ui desktop/web front end, dialogs, viewport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant