Skip to content

3D sketch: hold 3D points to model edges, planes, faces and the sketch's 2D curves (#10616) - #11481

Closed
Karl-VonRichter wants to merge 20 commits into
tangency-labs:mainfrom
Karl-VonRichter:feat/sketch-3d-dimensions-4
Closed

Karl-VonRichter wants to merge 20 commits into
tangency-labs:mainfrom
Karl-VonRichter:feat/sketch-3d-dimensions-4

Conversation

@Karl-VonRichter

@Karl-VonRichter Karl-VonRichter commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

In a 3D sketch, the points and lines drawn off the sketch plane can now be held to the model and to the sketch's own 2D geometry. A 3D point can sit on a model edge's end, on its line or on a circular edge's circle, on a 2D point, line, circle or arc of the same sketch, or on a construction plane or a planar face of a body. It stays there when the model or the 2D sketch changes. Distances and angles can be dimensioned from those faces and planes too.

This is the fourth of five pull requests for #10608 (dimensions and constraints in 3D sketches). Fixes #10616.

Builds on #10652, which builds on #10636 and #10609. Until they merge, this diff includes their commits. This pull request's own change is the commit after its claim: #10616 commit.

Changes a default: no

Evidence

A 3D sketch line on a 150 SHS beam (len = 3000), with a Ø40 pipe along it. Both ends are held on the beam's top face, the line is parallel to XZ, its start is dimensioned len / 2 from the near end face and its end 370 from the far end face. Then shs → 120 and len → 3500 (solidcraft-cli snapshot, the same camera):

shs = 150, len = 3000 shs = 120, len = 3500
before after

The runner goes down with the tube top and stretches to stay half the length from the start and 370 from the far end. This is the case #10608 was opened for, now from a script.

What changed

  • Held to model edges. A model edge brought into the sketch with sketch.include_3d is fixed geometry for the 3D constraints. A drawn 3D point can sit on its start or end (sketch.constraint.coincident), on its line (straight edges: Coincident, and Parallel, Perpendicular and Collinear with a drawn line), or on its circle (circular edges: the new point_on_curve kind). The line and circle come from the edge's exact curve. The included edge follows the model by its edge name, as included edges already do.
  • Held to the sketch's 2D geometry. A drawn 3D point can sit on a 2D point (the sketch origin too), line, circle or arc of the same sketch. The 2D geometry is placed through the sketch's plane, which the document stores on the sketch whenever its links are refreshed. A 3D curve fixed in the world cannot be held to 2D geometry.
  • Held to model planes. sketch.constraint.on_plane, sketch.constraint.parallel (a line and a plane) and sketch.dimension (a point's distance from a plane, a line's angle to it) take, besides xy, yz and xz:
    • a construction plane by name;
    • {face: [x,y,z], body?}, the planar body face through that point.
  • How a face is picked. The pick uses exact geometry only: the planar faces whose exact plane passes through the point, where SMLib classifies the point as on the body's surface. If those faces lie on different planes (a point on an edge), the pick is refused rather than guessed. The face is kept by its persistent face name and its plane is resolved again whenever the links are. cargo xtask mesh-decisions: no new mesh decisions.
  • Dimensions from fixed points. sketch.dimension takes two points where one is an included model point or a 2D point.
  • Refusals.
    • A constraint that holds nothing the 3D sketch can move is refused.
    • Fix only takes drawn 3D points.
    • A model plane that cannot be found leaves its constraint unsolved, with a warning on the sketch.
  • Paste. Pasting into another design drops constraints held to the source design's planes and faces, which the other design does not have.
  • Format. One pending file, sketch-3d-attachment.rs. A plane is still saved as "xy", "yz" or "xz", or as an object naming the plane or face. Older designs have none of these.

Not in this step:

  • Model vertices are reached as the ends of included edges. Including a vertex in a 3D sketch still makes a 2D point, as before: changing that would change existing sketches.
  • Curved faces are not plane targets: picking one exactly needs kernel work, which is paused.

Tests

Expected values are worked out by hand.

  • crates/sketch/src/wire_solve_tests.rs (+4):
    • a 3D line's start on an included edge's end, its end on the edge's line, a point on an included circle of radius 20, then a distance of 10 from the edge's other end;
    • points on a 2D point, a 2D line and a 2D circle through a sketch plane 10 above XY; without the plane they do not solve;
    • a point on a model plane that leans in XZ, unresolved first; saved, it keeps the face name and not the resolved plane;
    • refusals: two fixed points, a Fix on an included point, a world curve on 2D geometry.
  • crates/engine/src/cmd/sketch_3d_frame_tests.rs (+6):
    • a 3D line on a 2D point and line, following the 2D point when it moves;
    • a 3D line on an included box edge, following the box when its height changes from 10 to 25;
    • a point on a construction plane, following its distance from 5 to 8;
    • a point on a box's top face and a point 15 above it, refused on an edge between faces, following the height from 10 to 20, and found again after save and open;
    • a paste into another design keeping the origin-plane constraint and dropping the face one;
    • the beam runner above, through shs and len changes.
  • The step-1 test that expected a 3D point on the sketch origin to be refused now expects it on the origin.

Run here (Windows, ci profile), on main at 185c480:

  • clippy -D warnings on sketch, doc, engine and ui-egui;
  • solidcraft-sketch all 376;
  • solidcraft-doc with SMLib (its 3 failures also fail on a clean main checkout here);
  • 1,536 engine tests matching sketch, param, clipboard, component, hostile, inspect, schema, motion or script (one failure, intersection_curve_of_picked_faces_spans_the_whole_surface, also fails on a clean main checkout here);
  • cargo xtask lists, layers, skills, i18n --check, mesh-decisions; scripts/test-format-pending.sh;
  • cargo xtask ci: mesh-decisions reports no new mesh decisions. Of its 50 test failures, 37 also fail on a clean main checkout here; 12 pass when run alone (timing on this machine under the full run); the last, the kernel proptest scale_invariant, fails the same way on a clean main checkout with the same seed.

🤖 Generated with Claude Code

@github-actions github-actions Bot added area:doc timeline, components, parameters, naming area:sketch sketcher and constraint solver area:ui desktop/web front end, dialogs, viewport labels Nov 3, 2026
@Karl-VonRichter Karl-VonRichter changed the title 3D sketch: attach 3D points to model vertices, edges and faces and to the sketch's 2D curves (#10616) 3D sketch: hold 3D points to model edges, planes, faces and the sketch's 2D curves (#10616) Nov 3, 2026
Karl-VonRichter and others added 20 commits November 4, 2026 01:47
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cy-labs#10613)

The fit points of curves drawn in a 3D sketch take constraints of their own,
stored in `Sketch.wire_constraints` and solved in a pass after the planar
sketch, so planar sketches solve exactly as before and a 3D constraint never
moves planar geometry.

- Coincident (two 3D points, or a 3D point on a drawn 3D line), Fix and the
  new Along Axis (`sketch.constraint.along_axis`, with input and output
  schemas). 3D refs: `<curve>.start|end|through|<n>` or a 3D point's id.
- 3D Line joins the segments it draws with a Coincident at each joint.
- Move 3D Point solves the 3D constraints with the moved point held, and is
  refused when they cannot hold it there or the point is fixed.
- A conflicting 3D constraint is refused; deleting a curve takes its 3D
  constraints with it; the sketch's degrees of freedom count the 3D points.
- Fixed points are constants, as in the planar solve; each connected group is
  solved by damped least squares with central-difference derivatives.
- One pending format file; designs without 3D constraints are unchanged.

Part of tangency-labs#10608.

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

Review fixes for step 1 of tangency-labs#10608:
- The 3D solve has its own report (SolveReport::wires); planar edits measure the
  planar sketch's freedoms and conflicts again, and a failing 3D group no longer
  fails the planar sketch or blocks planar edits.
- Coincident points are one unknown, fixed points constants; each constraint's
  Jacobian is exact (forward-mode dual numbers), so freedoms count right far from
  the origin.
- Groups are capped at 1,500 unknowns and 3,000 residual rows, a solve has a
  work budget and gives up when it stalls, and drags skip the rank pass.
- Every drawn 3D curve joins the drawn ends it meets; curves drawn before 3D
  constraints are joined when the sketch is first constrained.
- A design whose 3D constraint names a missing fit point opens (it is dropped);
  a motion trace's rebuilt curve drops its constraints; foreign pastes map Fix
  points and axes; sketch.delete takes a curve with its own constraint;
  created and sketch.inspect list 3D constraints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…angency-labs#10613)

Second review round on step 1 of tangency-labs#10608:
- `solved` in a reply is the planar sketch's again (`wires_solved` beside it); a
  strict edit is refused for breaking the planar sketch only when it changed it,
  and for breaking the 3D constraints only when it changed them.
- A failing group no longer freezes the others; a solve that runs out of work
  says the sketch is too large to solve in time instead of listing conflicts.
- The work budget counts the multiply-adds actually done (linalg::solve_counted,
  rank_counted), the freedom count included; damping is scaled per unknown and a
  step moves no point more than a quarter of its group's size.
- A 3D line or arc squeezed to a point, or points thrown far, are refused as for
  planar curves.
- A motion trace's curve takes no 3D constraints and is not joined to; only a
  sketch's first 3D constraint joins existing ends, so a deleted joint stays gone.
- A paste's axis must map exactly onto an axis; saved 3D constraint ids may not
  be another entity's; move3d names a point fixed through a joint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…abs#10613)

Marquardt's per-unknown damping made a step favour some directions, so a solve no
longer moved points as little as it could (a lengthened line did not grow along
itself). The damping is the same for every unknown again, scaled by the largest
curvature so a group solves alike at any size, and a step moves no point more
than a twentieth of its group's size (more when a length or a dragged point has
further to go), so turning a line keeps its length.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…angency-labs#10613)

Third review round on step 1 of tangency-labs#10608:
- Freedoms are counted once every group is solved, so the count cannot use up
  the work a later group needs; a solve already within tolerance when the work
  runs out is kept; the row reduction works on row slices.
- A curve that cannot be rebuilt fails its own group, which stays where it was;
  the other groups are placed again without it.
- A strict edit is refused for the 3D constraints it breaks that held before it
  or that it adds, not for one failing elsewhere; a sketch too large to solve
  refuses only an edit that makes it so; running out of time says so.
- sketch.move3d refuses a move that squeezes a 3D curve away; a non-strict edit
  that would keeps the curves as the edit left them.
- A sketch stores that its curves were joined once (`wires_joined`): an older
  unjoined path is joined with the first curve drawn or constraint added, a
  deleted joint stays deleted, and copied 3D curves are joined where they meet.
- A motion trace's curve adds no freedoms to the count; its refusal is tested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gency-labs#10613)

Under the repository's testing rules, unit tests assert logic and geometry is graded by the
kernel-cases rig. The engine tests now check where the 3D solve puts the points only; the pipe
built along a line held parallel to X by Along Axis is the sweeps case
10613-pipe-along-a-3d-line-held-along-x, its volume, centre and box worked out by hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`sketch.dimension` takes 3D refs: a drawn 3D line's length, the distance
between two 3D points or along X, Y or Z only (keeping the side it was
measured on), the angle between two drawn 3D lines, and a drawn 3D arc's
radius. Each is driven by a model parameter (a value, an expression or
`name = expression`) or is driven (reference); a dimension the other 3D
constraints already settle is refused. Dimensions measure the sketch as the
current parameters solve it.

`sketch.line3d`, `.spline3d`, `.arc3d` and `.point3d` take expressions in
point coordinates: the point is held where they come to (a Fix that follows
them), in a sketch whose component is not moved.

The model parameters of 3D dimensions and the expressions of 3D points are in
use like their planar counterparts (not pruned, renamed, copied with the
sketch, carried into extracted and cloned components), through
`Sketch::dimension_params` and the sketch's expression lists. One pending
format file.

Part of tangency-labs#10608.

Review fixes: angles are smooth at their common values (0/180 hold lines
parallel; a parallel start is nudged off), an angle between lines that meet is the
corner's; driven dimensions need only be finite; a parameter change stores the solved
3D curves and is refused when it breaks the 3D constraints; script export, foreign
paste of point expressions, if_redundant and toggle_driven handle 3D dimensions.

Second review round: driven dimensions are checked as driven on every solve (any
finite value), errors name the constraint; a stalled start is nudged when no step
improves, only the constraints still off and by their own size; a parameter value a
3D dimension cannot take is refused; 3D dimensions are listed under created
dimensions and inspect gives their expression and degrees; a foreign paste maps
distances along an axis; a model entity beside a 3D ref is refused, not dropped;
the script export test replays the script.

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

A point a solve left a hair behind (rounding) no longer flips the side the dimension keeps.

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

An angle's residual in radians had next to no pull beside a length in mm once the lines were metres long, so a solve with both stalled (5 m and 20 m lines failed). It is now an arc length: the angle times the lines' size, taken as a constant of the step so shrinking a line gains nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cy-labs#10614)

Third review round on step 2 of tangency-labs#10608:
- A new angle dimension's parameter is written at full precision: rounded to six
  places it was off by more than an angle between long lines holds to, so a
  settled angle was refused as a conflict instead of placed driven.
- A parameter change is refused when this sketch's own 3D values cannot take it,
  not for any error (an upstream one is not the edit's to refuse).
- A stalled start is not nudged while a dragged point is pulled; the stall
  window starts again after a nudge; the nudge is the size of the constraint's
  own lines, not of the span between them.
- A value edit that squeezes a 3D curve away is refused; a new 3D dimension's
  bad value is said of the value; a count the work ran out on is not read as
  redundancy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…angency-labs#10614)

Session::world_state now returns a Result; the test helper that reads a solved 3D curve unwraps it.

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

Between drawn 3D curves: Parallel, Perpendicular and Collinear for two lines,
Equal for two lines (length) or two arcs (radius), and Tangent for a line and
an arc that meet at an end (the line along the arc's direction there, its end
held on the arc's end). The existing sketch.constraint.parallel,
.perpendicular, .collinear, .equal and .tangent take 3D refs.

To the origin planes of the sketch's 3D space: Parallel takes a line and
`xy`, `yz` or `xz`; the new sketch.constraint.on_plane holds 3D points on one
(with input and output schemas); sketch.dimension takes a 3D point and a plane
(signed distance, keeping its side) or a 3D line and a plane (angle, 0-90°).

Construction planes and model faces come with step 4 (tangency-labs#10616). One pending
format file.

Part of tangency-labs#10608.

Review fixes: Equal between arcs is an explicit `arcs` field (no prefix in wire
ids); Tangent holds the line leaving the arc the way it runs on (no cusp); the angle
to a plane is signed and smooth at 0 and holds the line square at 90; a parallel start
is nudged off for Perpendicular; On Plane takes plane names in either case; the planar
relation commands' help names their 3D refs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ngency-labs#10615)

Second review round on step 3 of tangency-labs#10608:
- Parallel, Perpendicular, Collinear, Tangent and the angle to a plane compare
  directions as units weighed by the lines' size (a constant of the step), so
  they solve beside lengths at building scale (near-parallel Perpendicular at
  5 m failed); with step 2's nudge on a stalled start, Equal arcs from a
  semicircle and a Tangent's fold-back solve too.
- A paste from another design maps the plane relations: onto the plane the paste
  turns them to, a shift along the normal making a point on the plane that far
  from it; one turned onto no origin plane goes.
- Making a driven angle to a plane driving keeps the side the line rises to; a
  side is only "behind" when clearly so, not by rounding.
- On Plane's label has its own pending file; strict mode takes plane names in
  any case and axis names X/Y/Z; the dimension help names the plane forms;
  Parallel's plane error says what it takes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ncy-labs#10615)

Third review round on step 3 of tangency-labs#10608:
- A paste from another design that shifts a distance from a plane along its
  normal rewrites the dimension's parameter to the shifted distance, so a solve
  keeps the point where the paste put it (it pulled it back); a turn only flips
  its side and keeps the value; an On Plane turned into a distance gets a
  parameter of its own.
- Collinear's and Tangent's direction rows no longer widen the solver's step, so
  a line they turn keeps about its length.
- Plane and axis names publish an any-case pattern, as strict mode takes them;
  their errors no longer repeat the key.
- Making an already driving angle to a plane driving keeps its side; the reply
  types plane_distance and plane_angle are taken as input; Equal's `curves` with
  3D curves says to give a pair; step 1's text file is left as it was.

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

Under the repository's testing rules, unit tests assert logic and geometry is graded by the
kernel-cases rig. The tangent test now checks where the 3D solve puts the line and that a loose
line is refused; the pipe along a line held on the XY plane by On Plane is the sweeps case
10615-pipe-along-a-3d-line-held-on-the-xy-plane, its volume, centre and box worked out by hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h's 2D curves (tangency-labs#10616)

A drawn 3D point or line can now be held to fixed geometry, which the 3D solve never moves:
- a model curve brought in with sketch.include_3d: its start or end (Coincident), its line
  (Point On Line, Parallel, Perpendicular, Collinear) or, for a circular edge, its circle (the
  new point_on_curve), read from the edge's exact curve, following the model by its edge name;
- a 2D point, line, circle or arc of the same sketch, placed through the sketch's plane;
- a plane of the model for On Plane, Parallel and distance and angle dimensions: a construction
  plane by name, or {face: [x,y,z], body?}, the planar body face through that point. The face is
  picked exactly from the B-rep's planes and SMLib's point classification (a point where two face
  planes meet is refused), kept by its face name, and resolved again whenever the links are.

Distances may run from an included model point or a 2D point. A constraint that holds nothing
the 3D sketch can move is refused. Pasting into another design drops constraints held to the
source design's planes and faces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Karl-VonRichter
Karl-VonRichter force-pushed the feat/sketch-3d-dimensions-4 branch from e515a0e to bacaf6e Compare November 4, 2026 03:43
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@bherbruck

Copy link
Copy Markdown
Collaborator

Thanks for this! I'm closing older PRs that have gone quiet or drifted from main, since a lot has changed in the last couple of weeks. If you'd still like this in, please open a fresh PR against current main; happy to review it.

@Karl-VonRichter

Copy link
Copy Markdown
Contributor Author

Reopened as a fresh PR against current main: #18383 (rebased onto #10652's updated head).

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:sketch sketcher and constraint solver area:ui desktop/web front end, dialogs, viewport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3D sketch: attach 3D points to model geometry and to the sketch's 2D curves

2 participants