Skip to content

3D sketch: dimensions and constraints on 3D lines, arcs and points #10608

Open

Description

@Karl-VonRichter

What are you trying to do

Lay out a weldment frame, or a frame line that leaves the base plane, in a 3D sketch, and drive its sizes with dimensions and parameters, as a 2D sketch does.

Today a 3D sketch line, arc or point is a set of world points (Wire.fit). The sketch solver never sees it, so none of these work:

  • a length, distance or angle dimension on it;
  • a parameter expression in its coordinates (sketch.line3d takes plain numbers);
  • a Coincident, Parallel or Perpendicular on it, or keeping it horizontal along an axis;
  • attaching its end to a model face, edge or vertex. Snapping while drawing copies the position and keeps no link.

The only way to change it is to move its points (sketch.move3d, or the triad in the view).

For a frame this breaks parametric design. In the 150 SHS beam below, the runner's line is drawn in a 3D sketch at z = 150, on the tube top. After shs changes from 150 to 120, the tube, plates, end cap and gussets follow. The runner stays at z = 150 and floats 30 mm above the tube:

runner floats after the tube size changes

Steps (any frame made from a 3D sketch):

  1. A parameter shs = 150 mm; a frame.member rect tube shs × shs along a 2D line on XY, anchored at the bottom.
  2. A 3D sketch with sketch.line3d from [1750, 0, 150] to [3130, 0, 150], then a frame.member on it.
  3. Change shs to 120 mm.

Expected: the line can be tied to the tube top (on its face, or dimensioned shs above the base) and follows it.
Actual: it stays at z = 150, and nothing in the sketch can tie it.

The workaround is to split a 3D frame into several 2D sketches on planes and faces, each dimensioned on its own. A frame that turns corners in 3D (a chassis, a space frame, a handrail) then needs one sketch per plane, and the lines that join them still can't be dimensioned.

Related: #8042 (#8035) makes the 3D commands reachable from the ribbon and notes that 3D wires are not in the solver. #741 (planar loops of 3D curves as profiles), #7831 and #7832 (3D curves as model geometry) and #4003 (frames, which take 3D sketch lines) are related but don't cover dimensions or constraints.

How you imagine it working

The common parametric CAD convention: a 3D sketch is solved like a 2D one, with points that have x, y and z.

Solved 3D geometry. Drawn 3D lines, arcs and points become solver entities with 3D points. Lines drawn one after another share their joint (a coincident). Fit splines can follow later; their fit points could be solver points too.

Constraints, under the existing sketch.constraint.* commands where the idea is the same:

  • Coincident: point to point, point on a 3D line or arc, and point on a plane or planar face (to put a frame corner on a face).
  • Fix.
  • Parallel, perpendicular, collinear and equal between 3D lines.
  • Along an axis: a line parallel to world X, Y or Z, the 3D counterpart of horizontal/vertical, and the constraint frames use most. Also a line parallel to a plane or face.
  • Tangent between a 3D line and a 3D arc. That gives a bent tube path (Create bent chassis tubes along connected sketch curves (#9792) #9793) with a dimensioned bend radius.
  • Attachment to model geometry: an end on a vertex, edge or face that follows it, using the face anchors plates and gussets already persist.

Dimensions (sketch.dimension with 3D references), each taking expressions:

  • the true length of a line, or the distance between two points;
  • the distance between two points along X, Y or Z only. A frame is dimensioned mostly by its run along each axis;
  • the distance from a point to a plane or planar face;
  • the angle between two lines, and between a line and a plane;
  • an arc's radius.

Drawing. While a 3D line is drawn, a segment close to an axis direction snaps to it and gets the along-axis constraint, as a 2D line gets horizontal/vertical. The plane being drawn on can be switched. Drawing on a plane inside the 3D sketch adds a constraint keeping those points on it.

Solver. The constructive pass and branch keeping (so edits don't flip the sketch) extend to 3D. Under- and over-constrained 3D sketches are reported as 2D ones are (degrees of freedom, refusal of conflicting constraints).

Format and compatibility. Existing designs keep their 3D wires as fixed points, with no constraints, so they evaluate as before. The design-format change is one pending file. Commands keep their ids; 3D refs are new fields.

Agents and scripts. sketch.line3d and its siblings accept parameter expressions in point coordinates, and constraint/dimension replies use the same created ids as in 2D. A frame can then be built and edited over MCP without face indices.

Suggested order, one PR each: (1) 3D points, lines and arcs in the solver, with coincident joints, fix and the along-axis constraints; (2) dimensions: length, axis distances, point to plane, angle, radius; (3) parallel, perpendicular, equal, tangent, on plane; (4) attachment to model faces, edges and vertices; (5) drawing aids (axis snapping, drawing plane).


Scope

Worked out from the current sketch code (crates/sketch/src/wire.rs, solver.rs, model.rs, and Document::solve_sketch).

How it is built

  • What is solved. The fit points of curves drawn in a 3D sketch (Wire.fit): a point has one, a line two, an arc three (start, through, end), a spline its fit points. Included, projected and intersection wires (those with a link) stay reference geometry and are never moved; a constraint may use their points as fixed.
  • Its own pass, after the 2D solve. Document::solve_sketch solves the planar sketch as today, then solves the 3D constraints with the sketch's 2D points fixed. A 3D point can lean on 2D geometry; 2D geometry never moves because of a 3D constraint. A sketch without 3D constraints solves exactly as before, and every existing 2D sketch is unchanged.
  • Stored separately. Sketch.wire_constraints holds the 3D constraints and dimensions (id, kind, param, driven), so the 2D ConstraintKind and its solver are untouched. Ids come from the sketch's own counters, so one constraint or dimension id names either kind.
  • References. A 3D point is <wire>.start, <wire>.end, <wire>.through (arc) or <wire>.<n> (fit point n). A whole curve is its wire id. These sit beside the 2D refs (l1.end), and commands take either.
  • Coordinates. A wire keeps its space (component or world). Axes and planes mean that space's axes and planes: a sketch in a component is constrained in the component's frame. A constraint between wires in different spaces is refused.
  • Joints. Curves drawn end to end from now on get an explicit coincident constraint at their joint. Old designs have no 3D constraints, so their wires stay where they were saved and evaluate as before; their joints keep today's rule (points at the same place move together). Moving a point (sketch.move3d, the triad) solves the constraints and moves what they tie to it.
  • Solver. A damped least-squares solve on the 3D unknowns, per connected group, using the sketch crate's existing linear algebra. It reports remaining degrees of freedom and conflicting constraints like the 2D solve, and refuses a new constraint that conflicts. From the stored state it keeps branches (which way an angle opens).
  • Commands. The existing ids: sketch.constraint.coincident, .fix, .parallel, .perpendicular, .equal, .tangent, .collinear and sketch.dimension take 3D refs. The new ideas get new ids: sketch.constraint.along_axis and sketch.constraint.on_plane. Each has input and output schemas. The design-format change is one pending file per PR that adds stored fields.

Steps (one PR each, stacked, each its own sub-issue)

  1. Solver and basic constraints: 3D points, lines and arcs as solver geometry; coincident (point to point, point on a 3D line), fix, along X/Y/Z; joints made when drawing; degrees of freedom and conflicts reported; sketch.move3d solves.
  2. Dimensions: true length of a line, distance between two points, distance along X, Y or Z, angle between two lines, arc radius. Each driven by an expression or parameter, or driven (reference). sketch.line3d, .arc3d and .point3d take expressions in point coordinates.
  3. More relations: parallel, perpendicular, collinear and equal length between 3D lines; tangent between a 3D line and a 3D arc; a line parallel to an origin or construction plane; a point on such a plane, with the distance and angle dimensions to planes.
  4. Attachment: a 3D point on a model vertex, edge or face, or on a 2D curve or point of the same sketch, following it through edits (the face anchors already used by plates and gussets).
  5. In the view: 3D constraint glyphs and dimensions drawn and editable in the viewport (double-click a dimension); drawing snaps a segment close to an axis to it and adds along-axis; the drawing plane can be switched.

Steps 1–4 are usable from scripts, MCP and solidcraft-cli, with a basic display of what they add; step 5 makes them comfortable in the view. Not in scope: splines' tangent handles, curvature continuity, 3D sketch patterns and mirrors, and model-level 3D curves (#7831, #7832).

Done when

The 150 SHS beam above is built with its runner on a 3D sketch line constrained to the tube top and dimensioned from the far end, and changing shs or len moves it with the tube, from a script and in the app.

Sub-issues

Activity

  1. added
    area:sketch
    needs-triage
    in progress
    on Nov 1, 2026
  2. github-actions commented on Nov 1, 2026

    @github-actions
    Contributor

    Claimed by @Karl-VonRichter through #10609. The claim lapses after 14 days without pushes.

  3. 48 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:sketchneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions