…ngency-labs#3890)
A drawing's source may now carry a path to another design file, relative
to the folder of the design the drawing is in. A source without a path is
the design the drawing is in, at most one of them, and a drawing lists at
most 64 sources by id.
- The record checks the count, the order, one source without a path and
every path (drawing.rs check_sources).
- One walk in design_link takes every link path of a design, component
links and drawing sources alike (map_paths, and linked_files to list the
files they name). Opening makes the paths whole (located); saving writes
them relative to the new folder (filed), through Save As, undo, redo and
checkpoints.
- drawing.create takes a source path, checks it as a component link's path
is checked and refuses a path that names the design itself.
- Which design a source means has one answer, Session::drawn: the design
the drawing is in for its own source. Another design's file is refused
as not supported yet, so a base view, a parts list and a sheet's
documents never take one, and a sheet that documents one shows its
fields as gone, never this design's.
- The format note is crates/doc/src/drawing/format/pending/source-paths.rs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Requested by Cam
Change
A drawing can now name another design file as what it draws. Until now, a drawing drew only the design it is saved in. This PR is the record and the paths only: the drawing keeps the other file's path, and the path stays right when the design is saved somewhere else, undone, redone or recovered. Reading that file and drawing its views come in the next parts.
This is the first of a series (L1 to L6 of #3890). It sets the shape the rest build on (a source with an optional path, and one walk over every link path), so it asks for a design review before the later parts go up. Part of #3890, into
drawings.Changes a default: no
A drawing made without
sourceis saved and read exactly as before.What it adds
path, written only when present. A drawing has at most 64 sources, listed by id, and at most one without a path (the design it is in). A path isn't empty, only spaces, or holding control characters. One pending format note,source-paths.rs.drawing.create {source}names another design file to draw. It is refused, with nothing changed, for: a text over 4,096 bytes; a network or device path; a file that isn't a design; the design's own file in any spelling (sub/../case.sctoo); a file that isn't there. The path is kept whole in memory and relative to the design's folder in the file, as Insert Design keeps a component link (component_link.rs:556).drawing.inspectlists each source as{id, path?}, the path as the file keeps it.design_link.rs):map_pathstakes every link path of a design, component links and drawing sources alike, through one map. Opening makes them whole (located). Save As writes them relative to the new folder (filed).linked_fileslists each file the links name, once. The two old link walks are now one line each over it.Session::drawn(drawing, source). Every reader asks it: base views, new parts lists, a sheet's documented component, and the title block's and notes' fields. In this PR a linked source answers "not supported yet: reading a linked design (Drawing W11, W12, W15: where drawings are saved, their records and their commands #3890)", so nothing reads the wrong design. The next part makes it open the file.Decisions
DesignLink.pathhas no cap either, and a relative text kept in memory would break "whole in memory": the next Save As or undo would rebase it from the wrong folder. So the 4,096-byte limit is on thesourceparameter only. A deep folder that makes a longer whole path still works; a test covers it.DesignLink.file_sha256(Linked components: a part file changed while the assembly was closed isn't picked up when the assembly opens, and component.links doesn't say it is out of date #9739). Which file a drawing draws is a path. Whether that file changed is the next part's question, answered when it opens the file.a/../p.scandp.scare one file. A record that opened and then failed its check would block every edit of that drawing.crates/format/src/newer.rs:120-124at v0.40.1). Adrawingsbuild from before this PR refuses the design as "saved by a newer SolidCraft". Nothing is dropped. Only unreleased builds can meet this.Known limits
sourcetext is resolved against the program's working folder, as Insert Design does.drawing.create's default template and name still come from the design the drawing is in, also for a drawing of another file. Until the next part can read the file, passtemplatewithsource.Validation
Local, Windows,
--profile ci, Rust 1.99.1.On
drawingsdb49054, 15 Nov 07:55 UTC:drawing134 passed; iodesign::drawing,mutate::designsanddesign::provenance38 passed; engine drawing, design-link, component-link, file, schema, scene and title-block tests with the registry 1,304 passed (3 ignored, as ondrawings); hostile params passed.drawing.createtaken out) was missed at first; the second commit adds the check that catches it (below), and it was caught at 09:40 UTC. Faults 9 and 10 (the walk and the source accessor) ran in the earlier group run with the next part.On
drawings8647608 after the last rebase, 10:09 UTC: clippy -D warnings of doc, io and engine (all targets), rustfmt, and the engine's drawing command tests, the design-path scan test and the registry check: all passed (32 tests).The second commit: the order of the network check.
drawing.createrefuses a network or device path from its text before it compares the path with the design's own file. That comparison canonicalises the path, which would touch the network. Without the check, the reply is the same, because the presence check later refuses the path with the same text. So no reply test can see the order. The existing design-path scan test (every_link_path_goes_through_the_design_path_rule) now checks it, as it already does for Relink.drawing.create {source}: each refusal above with nothing changed, 4,096 bytes still looked for, the design's own file in another spelling;What the tests don't reach:
sourcetext that exists.Screenshots of the behavior
UI: none. There is no picker for a source yet; it comes with the later parts and the drawing UI. The evidence is
drawing.create's reply, which answers asdrawing.inspect, for a drawing of another design file:The reply, cut to the drawing's id, name and sources (the folder is shortened here):
{ "id": "9na55vkffykys", "name": "Bracket drawing", "sources": [ { "id": "364vpyycqnksq", "path": "<folder>\bracket.sc" } ] }The design was not saved yet when the drawing was made, so the path is whole. Once the design is saved,
drawing.inspectshows it relative to the design's folder.Integration status
Rebased onto
drawings8647608, 15 Nov 2026. Three conflicts on the way, each indrawing.inspect's parameter text, and each resolved to keep both: with #16838 (view_letters), with #17127 (each sheet's notes, tables, images and revision tags) and with #13064 (the drawing's symbols). One change git doesn't flag: a test the last drawings sync added inio/src/design/provenance.rsbuilds a source asSource { id }. It now readsSource { id, path: None }.git merge-treeagainst each open PR intodrawingsthat changescmd/drawing.rs,drawing_tests.rsorcomponent_link.rs(#16144, #13033, #7608): no new conflict for any of them. Our #16842, #13058 and #3876 add a function besidenew_listincmd/drawing_table.rs, which this PR changes. Whichever lands second keeps both.Follow-ups, not in this PR:
drawing.create, Insert Design, Relink, the link reader and the pack each write it a little differently.iothat nothing calls since drawings moved into the design.drawing.createjudges a source path's network rule twice: once directly, and again in the presence check. One call that refuses, compares and checks presence in order would remove the repeat.