Skip to content

Drawings: a balloon, dimension or note attaches only to a part its view draws (#4896) - #12394

Merged
bherbruck merged 1 commit into
tangency-labs:drawingsfrom
CamWight:annotation-shown-only-4896
Nov 6, 2026
Merged

bherbruck merged 1 commit into
tangency-labs:drawingsfrom
CamWight:annotation-shown-only-4896

Conversation

@CamWight

@CamWight CamWight commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Change

A drawing view can leave parts of an assembly out: its saved settings choose which occurrences it draws (source) and which it hides (hide). In the app you can only pick what a view draws. Through a command (a script, the control channel or MCP), though, drawing.balloon.add accepts a balloon on a part the view hides. @Benny1496 found this on #11881. drawing.dimension.add and drawing.note.add (a leader on an edge or a corner) have the same gap: each one makes its model reference without asking whether the view draws that part.

This makes the view's rule the one door:

  • Adding is refused when the view doesn't draw the part. The refusal names the view and the setting that leaves the part out, for example "view V doesn't draw that part: its hide leaves out occurrence P", plus "(set on view Q)" when a parent view set it. A refusal changes nothing.
  • The rule stays in one place. The view already decides what it draws from the occurrence paths alone (chosen in drawing_view.rs). A new left_out(view, path) asks that same rule about one path and says why. One shared check (check_drawn in cmd/drawing_view.rs) calls it for all three commands, after their references are made (so a bad path still gets its own error first). It resolves the view once per command, however many points a chain has. No model is evaluated, and the commands stay as cheap as they are.
  • An annotation added before a later view edit hid its part stays where it is and is drawn as now. Its inspect reply gets a warning ("view V doesn't draw this part now: …"). The view edit is never refused for it.
  • Edits can't change what an annotation points at, and a repair keeps its own path, so add is the only way in.
  • Where a setting was set is said by one function, set_on. On drawings, Drawings: a drawing, a sheet or a view saves the line group its lines are drawn in (#4890) #12516 (line groups) gave a resolved setting two more setters: the view's sheet and the drawing. set_on has an arm for each. A parent names its view, and a sheet and a drawing say so. A view's own setting and the default add nothing. Today hide and the chosen occurrences come only from a view's chain, so no refusal says "its sheet" yet. The match makes the compiler check each new setter.

Part of #4896 (dimensions and notes) and #3874 (balloons), into drawings. Drawing data only, no kernel geometry.

Changes a default: no
Only calls that attach to a part the view leaves out are refused; the app's own picks never do, and no setting changes.

Validation

Local, Windows, --profile ci, on drawings a7c0310 (one commit, 1872f0943):

What the tests can't reach:

  • The branch for a view that can't be resolved (no refusal, no warning). An add checks the view exists first, and deleting a view takes the annotations in it, so it is defensive only.
  • A projected view whose parent set source. Its words come from the same code as the tested inherited hide, but no test sets a parent source.
  • The cylinder, silhouette, faces, radial, angle and length dimension kinds. Only linear and chain dimensions are refused in tests. Each kind is one arm of an exhaustive match, and the planted fault "a chain checks only its first point" shows the walk is used.
  • A note's corner leader on a projected view.

The real program, a release build of this commit driven through its control channel, on a plain test assembly (a 40 x 30 x 20 mm Block component and a Base box beside it), with a front view at 1:1, a balloon and a 40 mm dimension on the Block:

  • hidden with drawing.view.edit {"hide": [[2]]}: both inspects say "view … doesn't draw this part now: its hide leaves out occurrence path [2]";
  • a new balloon on the Block is refused: "view … doesn't draw that part: its hide leaves out occurrence path [2]";
  • shown again ("hide": null): the warnings go. No crash reports.

Screenshots of the behavior (when observable)

The sheet as the app exports it (drawing.export, PNG). Balloons and dimension text don't draw on drawings yet (the text PRs #12356 and #12357 add the text).

Before the hide, the Block (left) and the Base, with the Block's dimension:

The sheet before the hide: the Block and the Base drawn, the 40 mm dimension under the Block

After the hide: the view draws only the Base and is centred on it again; the dimension added before the hide stays, and inspect warns about it:

After the hide: only the Base drawn; the dimension added before the hide stays

Integration status

One commit on drawings a7c0310 (the latest when pushed). It is rebased onto that commit because #12516 gave a resolved setting two more setters; the earlier commit didn't compile there. Other open work nearby: @armin0411's #9421 (manual centre marks and centre lines) adds two more commands that attach to a model edge or corner. Whichever of the two merges second calls the same check, so the rule covers them too.

@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@theironchef theironchef left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read at c406d80b0 (source only, not built locally).

CI's red is a semantic conflict with drawings, not this change's logic. "Quick compile" fails with E0004 at crates/engine/src/cmd/drawing_view.rs:334: SetBy::Sheet and SetBy::Drawing aren't covered. #12516 (ecf75d908) added those two variants after this branch was cut. GitHub still shows the PR as mergeable because the merge has no textual conflict. The other failing jobs ("Build the CLI", "kernel-rig", "ci") look like the same compile error.

Today only line_group resolves to those two (doc/src/drawing/view.rs:287-288); source and hide never do. So the fix after rebasing is just to cover them in set_on, for example:

let set_on = |set_by: SetBy| match set_by {
    SetBy::Parent(parent) => format!(" (set on view {})", ids::encode(parent)),
    SetBy::Sheet => " (set on its sheet)".to_string(),
    SetBy::Drawing => " (set on the drawing)".to_string(),
    SetBy::This | SetBy::Default => String::new(),
};

(Or leave those two out of the words with the empty string, since source and hide can't come from them yet. Either way, naming every variant keeps the next one from slipping through as _.)

On the change itself:

  • The refusal only needs to sit on add. I checked that drawing.dimension.edit (DimensionSet), drawing.balloon.edit and drawing.note.edit can't point an annotation at a different reference ("to measure/point at something else, add a new one"), so editing can't get round the check.
  • DimensionKind::paths covers every kind, and a chain checks each of its points, which the test pins with the hidden last point.
  • An unresolvable view gives no refusal from not_drawn and leaves it to the view's own reply. That seems right, and it's documented.

…ew draws (tangency-labs#4896)


Adding one on a part the view's saved settings leave out (its hide, or a source that doesn't
choose it) is refused, naming the view and the setting, and the parent view when it set it. One
added before a later view edit stays, and its inspect reply warns until the edit is undone.

The rule stays the view's own (`chosen`): `left_out` asks it about one occurrence path and says
why; `check_drawn`, `not_drawn` and `drawn_warning` beside the view commands use it for the three
annotations. `DimensionKind::paths` and `Anchor::path` list what each points at, so every kind of
dimension is checked. No model is evaluated.

On drawings a7c0310, tangency-labs#12516 (line groups) gave a resolved setting two more setters, the
view's sheet and the drawing. The words for where a setting was set are one function, set_on,
with an arm for each: a parent names its view, a sheet and a drawing say so, and a view's own
setting and the default add nothing. Hide and the chosen occurrences come only from a view's
chain today, so no refusal says "its sheet" yet; the match keeps the compiler checking each
new setter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CamWight
CamWight force-pushed the annotation-shown-only-4896 branch from c406d80 to 1872f09 Compare November 6, 2026 20:22
@bherbruck
bherbruck merged commit 67a3258 into tangency-labs:drawings Nov 6, 2026
32 checks passed
Benny1496 added a commit to Benny1496/solidcraft that referenced this pull request Nov 6, 2026
github-actions Bot pushed a commit to Benny1496/solidcraft that referenced this pull request Nov 6, 2026
@CamWight
CamWight deleted the annotation-shown-only-4896 branch November 7, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants