Skip to content

Drawing W38: sketches on sheets and views, with projected view geometry and fills #5425

Open

Description

@CamWight

Part of the Drawings plan in #860 (consolidated plan, package W38): sketching on a drawing, on a sheet or on top of a view, with the view's own geometry brought into the sketch.

Supported cases

  • Sketches on a sheet or a view:
    • a sheet sketch is at paper scale;
    • a view sketch belongs to its view: it uses the view's frame and scale, and moves and scales with the view;
    • neither ever changes the model or its sketches;
    • SolidCraft's own sketch tools, solver and constraints, with dimensions shown on the sheet.
  • Projected view geometry: the visible edges of the view a sketch belongs to can be projected into it, as references to the model through W13's references (Drawing W13, W14: references that survive model edits, and updating drawings when the model changes #4892). A projected line follows model edits, times the view's scale. When the model edge is deleted, it keeps its last geometry and reports a lost reference, the way projected sketch links work today (crates/doc/src/project.rs); it never vanishes. Hidden lines and thread representations aren't projected.
  • Fills and hatches on closed regions, kept apart from the hatch a section view draws by itself. Also images placed on a sheet.
  • Draft views: a view with no model, at its own scale, holding sketches.
  • Commands for all of it, starting with drawing.sketch.create {owner: sheet | view}, with predictable snapping and undo per drawing (Drawing W11, W12, W15: where drawings are saved, their records and their commands #3890).

Non-goals

Section views and their hatch (W34), break-out boundaries (W17), and editing model sketches from a drawing.

Tests

  • A 50 mm line in a 1:2 view sketch is 25 mm on paper.
  • A line projected from a view edge follows a 10 mm model change at the view's scale.
  • Deleting the edge leaves the line at its last geometry, with a lost reference.
  • Undo and redo of each sketch edit in the drawing's own history.
  • A fill on a closed region exports to SVG and PDF as a fill.

Merge dependencies

W10 (the paper scene, #4890), W12 (drawing records, #3890), W13 (references, #4892), W15 to W18 (commands, the workspace, views and sheets). The sheet sketch can start on records alone; view sketches and projection follow W17's views.

Related: #4563 and #4565 (SS-EN's viewport section hatch) and #2068 (section curves).

Activity

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

    @github-actions
    Contributor

    Claimed by @CamWight through #5426. The claim lapses after 14 days without pushes.

  3. CamWight commented on Oct 23, 2026

    @CamWight
    ContributorAuthor

    The plan

    I've claimed this in #5426. Here's how I'd like to build it, posted before any code. It follows the parity study's notes on sketches in drawings, draft views and hatching (the study on #860), and a map of today's sketch code at main 858e599.

    What a drawing sketch is

    • Today's Sketch, unchanged, stored in the drawing (Drawing W11, W12, W15: where drawings are saved, their records and their commands #3890's records) with an owner: a sheet or a view. The sketch crate doesn't depend on doc, so nothing in it changes.
    • A sheet sketch works in paper millimetres, 1:1.
    • A view sketch keeps model millimetres in the view's basis (Drawing W17a: view definitions as data (direction, first- or third-angle projection, scale) #4816), and the view's placement applies its scale. So a 50 mm line in a 1:2 view is 25 mm on paper and dimensions as 50, and changing the view's scale changes no sketch data.
    • A draft view is a view with no model: its own basis and scale, holding sketches. A DXF or SVG can be imported into it, through today's add_geometry.
    • Expressions from the start: a drawing sketch's dimensions, points and texts can use the parameters of a source design, read-only. A view sketch reads its view's design; a sheet sketch reads the design its sheet documents. A name that design doesn't have is refused with a message, and a drawing sketch never makes a model parameter.

    The same tools

    • The existing sketch.* commands and tools work on the active drawing sketch in a drawing session. drawing.sketch.create {owner} and drawing.sketch.edit start one, and sketch.finish ends it.
    • Commands that only mean something on a model are refused with a message: projecting to a surface, intersection and isoparametric curves, 3D sketches, slices, and projections of model references.
    • One sketch store first (W38.0). The sketch commands find and save their sketch in one place (target_sketch and edit_solved), plus about twenty direct reads and writes. They'll go behind one store, chosen by the session's kind, as a small PR to main with no change in behaviour, before any drawing slice. About 40 open PRs touch those files, so it's kept small and early.

    Projecting the view's geometry

    • On request: the visible edges of a view can be projected into its sketch as links, through Drawing W13, W14: references that survive model edits, and updating drawings when the model changes #4892's edge references. They aren't projected automatically when a sketch is made.
    • Associative: a projected line follows model edits at the view's scale. When the model edge is deleted, it keeps its last geometry and reports a lost reference, as projected sketch links do today; it never vanishes. Break Link makes it plain geometry.
    • Only visible edges are projected, not hidden lines or thread representations. Each projected line links to one model edge, so an edit splitting or joining the view's pieces rebuilds as little as possible.
    • It needs the hidden-line pieces to name their model edge (W06/W17): today's view export gives no source.

    Fills and hatches

    • On any closed region of a drawing sketch, found again by its boundary curves after edits. When those curves are gone, it keeps its last region and reports it.
    • Built-in patterns (solid, ISO's 45° lines and a cross-hatch, with angle and spacing editable), and .pat file import in the same slice. Every number is checked, the counts are capped, a bad line is refused with its line number, and imported patterns are saved in the drawing so it opens anywhere.
    • Kept apart from section hatching (W34), which follows material and the standard's angle rules.

    On paper and in exports

    Strokes from the sketch's exact curves, text as filled glyph outlines, fills as fills, and hatches as strokes clipped to their region, all through the paper scene (#4890), so every export gets them. Centre lines wait for the paper scene's line patterns.

    The order

    1. W38.0: the sketch store (to main).
    2. W38a: sheet sketches.
    3. W38b: view sketches and draft views.
    4. W38c: projection.
    5. W38d: fills, hatches and .pat import.
    6. W38e: images on a sheet.
    7. Later: .pat export and sketch dimensions shown on the sheet.

    For anyone working nearby

    If anything here clashes with what you're building, tell me and let's fit the two together.

  4. CamWight commented on Oct 24, 2026

    @CamWight
    ContributorAuthor

    The plan for W38.0, the sketch store: the first slice, its own small PR to main, with no change in behaviour.

    Why. The sketch commands find the sketch they work on, and save it back, in about 40 places, each its own way:

    • target_sketch (16 calls);
    • edit and edit_solved (about 50 calls, one store path);
    • 13 copies of active_sketch.ok_or_else(…), with three different refusals;
    • 10 copies that clone, change and store a sketch without the solve or the checks (text, import, links and projections);
    • 9 direct reads.

    W38a and W38b need these same commands to work on a sheet's or a view's sketch, so first they all go through one door.

    The change. One module, cmd/sketch_store.rs:

    • target: today's target_sketch, moved;
    • active: each caller keeps its own refusal;
    • read and write: the only calls to Document::sketch and sketch_mut from the sketch commands;
    • update: the clone, change and store pattern, written once, doing exactly what the copies do now;
    • checked: the two validators edit_solved and sketch_modify already run.

    edit and edit_solved stay where they are, and load and store through it. Reads and writes that are about the design itself stay as they are, each marked // design-only:: a live drag's display, parameter edits, Redefine Sketch Plane, motion traces and joint references. In W38a, target, read and write learn about drawing sessions, and the commands don't change again.

    What stays the same: behaviour, messages, the file format, every command and parameter, and the solver. So does what each copy checks today: the link and text writes don't start running checked here, because that could refuse an edit that works now.

    Tests:

    • every sketch test, unchanged;
    • one new source-scan test, in the style of navigation.rs's camera-input guard, which names the file and line when a sketch command reaches past the store;
    • planted faults and the gate.

    Nearby:

  5. added this to the Drawings milestone on Oct 25, 2026
  6. CamWight commented on Oct 26, 2026

    @CamWight
    ContributorAuthor

    @0xlillith, a second handover for your team: W38d, fills and hatches on drawing sketches with .pat import, is yours from now, if you'd like it. Thank you!

    What it is: a fill or a hatch on any closed region of a drawing sketch, with built-in patterns (solid, ISO's 45° lines and a cross-hatch, angle and spacing editable) and .pat file import in the same slice. .pat export comes later. It stays apart from the hatch a section view draws (W34), which follows material and the standard's angle rules.

    The plan:

    • The record: SketchFill { id, sketch, boundary: WholeProfileBoundary, paint }, with paint either Solid or Hatch { pattern, angle, spacing, offset }. The region is found again from its boundary curves (profile_by_curves) after edits. When those curves are gone, it keeps its last region and reports it, as a lost sketch link does today.
    • Patterns are paper millimetres at scale 1: a 3 mm spacing prints 3 mm at any view scale. Imported patterns are saved in the drawing, so a drawing opens anywhere without the file.
    • On paper: fills as the paper scene's Fill items; hatches as strokes clipped to the region when the scene is built, so every export gets them. New paper kinds sketch and fill, on layers SKETCH and FILL.
    • The .pat format (from the public reference): a header line *NAME, description (the name at most 31 characters, of letters, digits, _, - and $); then one line per family of parallel lines: angle, the x and y of a line through the origin, delta-x (the shift along the line between members), delta-y (the spacing), then up to six dash lengths (positive draws, negative is a gap, zero a dot). At most 80 characters a line; blank lines and text after ; are ignored. A .pat file has no units, so import takes units (millimetres by default) and a scale, and shows the resulting spacing in paper millimetres before it's confirmed: an imperial file read as millimetres comes out 25.4 times too dense.
    • Hostile input: every number finite and bounded; a file over 1 MiB, more than 1,000 patterns, more than 64 lines in a pattern, or a delta-y of zero is refused; a malformed line is refused with its line number; a hatch that would need more lines in a region than the cap is refused, never cut short.
    • Licensing: other products' pattern files are never shipped, embedded or copied. The built-ins are defined in code from the public convention (ISO 128-3 clause 7), and user files are the user's data, read when imported.

    Tests from the plan:

    • a 40 × 20 mm rectangle hatched at 45° with 5 mm spacing has the line count and lengths worked out by hand, and a .pat with one 45° family gives the same;
    • malformed lines are refused with their line numbers: 82 characters, seven dash lengths, NaN, a bad name;
    • a hole is left unhatched;
    • a fill whose boundary curve is deleted keeps its last region and reports it;
    • the cap on lines per region refuses rather than cuts;
    • fuzz: a changed drawing file with fills gives an error or a drawing, never a panic.

    One point to settle when you build it: our plan's tests also refuse a file with no blank line after its last pattern (the reference needs one), while the research suggested accepting it with a note. Either is fine with us, as long as it's stated and tested.

    What it sits on: fills attach to drawing sketches, which need W38.0 (one sketch store for the sketch commands, #6336, in review on main) and W38a (sheet sketches: the drawing's sketch record, not built yet). The paper scene is already on drawings. The pattern model, the .pat reader and the hatch lines for a region are plain functions with no drawing record, so they can start straight away, and the record joins them once W38a is in.

    Claims: please open its own issue and a draft claim from your team, based on drawings, and link it here. I'll mark the slice as yours in our plan. Happy to help with anything along the way.

  7. selun3 commented on Oct 26, 2026

    @selun3
    Collaborator

    @CamWight, accepted both handoffs: W38d fills/patterns/PAT and, following your later reply, W38a sheet sketches. Your SVG work and W38b/c/e stay outside our scope. PDF #4890 follows SVG as agreed.

    For W38d we require a real final blank PAT line and document the choice. We ship only original patterns/tests. The later saved-fill resolver will preserve outer-plus-holes identity; today's outer-only profile_by_curves match must not silently refill a deleted hole. Bounded Line regions plus the documented canonical circles/one concentric hole are implemented and validated; general curves and saved records/paper output remain later slices.

    One gate prerequisite to coordinate: the frozen drawings runner launches all test binaries plus wasm/doc concurrently. Our machine uses one builder and one heavy command at a time; Cargo/libtest job limits alone do not bound that runner. The existing xtask/src/test.rs change from merged #5494 provides SOLIDCRAFT_TEST_JOBS=1, with the native binaries and wasm/doc in one queue. Its old blob is exactly this branch's runner. Can we bring only that runner change into Drawings as a separate prerequisite, preserving its attribution? We would validate the actual receiver with the normal cargo xtask ci; no foreign runner or substitute gate. Focused library work continues while this is settled.

    Tool handoff: Judit has asked us to stop and preserve all work. Code, tests, results and next steps are saved in #7064, #6184, #6163, #7082 and the RFC checklist. The local team and automatic follow-up are stopped. Existing questions remain open; no additional execution or gate waiver is implied.

    Current follow-up: the same prerequisite on the PDF base

    Cam, Judit has resumed the team on the assigned Drawings units; the older tool-stop note above is historical. We are now preparing the independent P2 test-only helpers against the actual #7626 head 506d4190, leaving your B1/text contract pending. The full local gate passed on the separate DXF draft d8e7a869; that result does not qualify this PDF source.

    The PDF base still has the parallel runner. Source comparison confirms its runner matches the original old blob 799c820f7d1b346bc788c27814a96db29c6355fd from #5494. The original one-file change produces blob 3837d49e80325598735b540b84dc828d634246b1, including its four original tests, and needs no dependency/main/workflow change. We can preserve its attribution and extract just that file; the aggregate integration commits would not be adopted.

    Your answer to the existing single-runner prerequisite question above is still pending. We have prepared only a private source proposal and have not changed the PDF runner or used a substitute gate. Real dependency resolution and focused prototype validation can proceed separately; full cargo xtask ci on this receiver remains pending that legitimate serial route. W38 WIP is preserved, while the current delivery priority stays with the assigned W10/W21/W22 and DXF units.

    For a reviewable source reference, the isolated original #5494 runner delta is now stored in the canonical repository proposal branch, commit e65a33d3e3dfd36911b782df578e8b491dd1341f. It remains a proposal, unapplied to the PDF candidate and unexecuted. The existing owner question above is still pending; this checkpoint is not a gate waiver or an execution request.

  8. 56 remaining items

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

Metadata

Metadata

Assignees

Labels

area:sketchin progressneeds-triage

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions