Repository navigation
Closed
Labels
area:ioimport/export and file formats (STEP, IGES, 3MF, glTF, designs)in progresssomeone is working on it (see comments)needs-triageno priority yet; a maintainer sorts it with /triage
Description
What happens
write_dxf_drawing(layers, entities) (crates/io/src/dxf_out.rs:328-547) takes the layer table and the entities as two lists joined by strings. On main (edf57ce):
- An entity names its layer as a string (
DxfEntity,:107-112, built by hand at eight places). The writer builds the LAYER table fromlayersalone (:343-348) and writes whatever layer an entity names (:440), so an entity can sit on a layer the table doesn't have. Each caller rebuilds the table to match: the flat pattern collects its entities' layer names and looks each one up indxf_layer(crates/engine/src/cmd/sheet.rs:597-609,:742-746); the view DXF addsHIDDENandSKETCHfrom flags (crates/engine/src/cmd/view_dxf.rs:84-90). - Callers read the writer's records back:
connectpicks the hidden lines out bylayer == "HIDDEN"(crates/engine/src/cmd/view_dxf_projection.rs:41) and names the layer again for the polylines it makes (:74). - Layer names go into the file as given (
:386,:440). Every layer name onmainis made by the code, but the first layer named after a body, or by a user, can carry a newline that breaks the whole file. - There are no line weights: nothing writes group 370. Drawings need a weight per layer, with some entities heavier or lighter than their layer.
- Extents are worked out inside the writer (
:331-341) and nobody else can ask for them, and nothing moves or scales what's been built. Placing a view or a title block on a sheet needs both. - TEXT has one alignment, centred on its baseline (
:509-514), so any other placement has to be offset by hand.
Proposed
I'd suggest a DxfFile in dxf_out: the DXF file being built.
- Layers: declare a layer once, with its name, colour, line type and a default weight, and get a handle back. Entities are added to a handle; any entity may override its layer's weight.
- Weights: snapped to the nearest of the 24 standard line weights (0 to 2.11 mm); a weight over 2.11 mm is refused, never clamped. The paused paper DXF slice's
Lineweighttable moves in here. - Names: cleaned once, in one place (control characters and the characters a layer name can't hold become
_; an empty name is layer0, as:440does today). - Tables: the LTYPE, LAYER and STYLE tables come from what the file holds, keeping the records every file has today (layer
0,ByBlock,ByLayer,Continuous,DASHED, theStandardstyle), so today's files keep their bytes. - Extents, moving and scaling: the file gives its extents, and can be moved and scaled as a whole.
- TEXT alignment: left, centre or right × baseline, middle or top (groups 72 and 73). The bend notes' centre-on-the-baseline is one of them.
- Serialising stays in the private
Out(:243-313) and happens once, when the file is written.
The flat pattern and the view DXF move onto it in the same PR:
- the flat pattern declares its layers from
dxf_layer's table, and the name set atsheet.rs:742-745goes; connecttakes the hidden lines as lines, before they're entities, so nothing matches a layer string;write_dxf_drawingandDxfEntityare deleted.DxfShapestays as an entity's geometry, and DXF: one place that turns a curve path into entities, and can refuse what it can't write #5318's styles produce it.
Tests:
- Byte pins: DXF: one place that turns a curve path into entities, and can refuse what it can't write #5318's flat-pattern pins, plus the view DXF with hidden lines omitted and dashed and with a sketch shown, prove the files don't change.
- The built file, asked directly: which entities are on which layer, with which weight and line type.
- Weights at every edge: 0, each standard value, halfway between two of them, 2.11, just over 2.11, negative, NaN and infinity.
- Names: a newline, a reserved character, an empty name, a very long name; and two names that clean to the same one (refused, I'd suggest, rather than merged).
- Extents with text, after moving and scaling; and each of the nine alignments, with its groups 72 and 73 and its alignment point.
What stays the same: every file the flat pattern and the view DXF write today, their commands and options, and the layers' names and colours.
Order
After #5318 (one place that turns a curve path into entities), which follows #5269. Tests on the built file and a layered read (#5320) follow this, then one DXF writer (#5321).
The paper DXF slice of #4890 (A2) is paused and will be rebuilt on this.
Reacted by Dahak Builds
Metadata
Metadata
Assignees
Labels
area:ioimport/export and file formats (STEP, IGES, 3MF, glTF, designs)in progresssomeone is working on it (see comments)needs-triageno priority yet; a maintainer sorts it with /triage
Activity
feat(dxf): preserve owned file model and shared writer WIP (tangency-…
feat(dxf): preserve layer-zero imports and nine TEXT alignments (WIP t…
selun3 commentedon Oct 28, 2026
Cam, I'm recording the implementation choices for your plan here so the interface assumptions are visible; no reply is needed before the time you mentioned.
AlignedTextvariant keeps existingTextcentre/baseline behaviour and bytes intact. Its writer requires caller-supplied layout bounds rather than guessed font metrics; the actual font/layout provider is still pending.The current source is preserved in stacked draft #8515 at
471e17f5, over #8435. These are our proposed seams, not completed caller migration or a change to your paper/text ownership. Legacy API removal and original byte-pin validation remain outstanding. The new source has not been compiled or run; the older frozen validation run cannot qualify it.Caller migration: admission contract to settle
Cam, while preparing the flat-pattern/current-view adapters, we found a source-level difference that affects the unchanged-behaviour requirement in this issue. On our current draft d8e7a869, the owned writer bounds geometry work to 1,000,000 values (a LINE charges two points), output to 64 MiB, and entities to 1,000,000. The current-view producer has separate ceilings of 1,000,000 output lines and 4,000,000 scene segments/sketch points. Its legacy serialization route does not apply the same owned-file admission checks. The owned writer also rejects geometry that collapses under the existing twelve-decimal encoding.
These budgets count different things, so simply replacing the writer call is not proof of an unchanged accepted domain. This is a static integration finding, not a reproduced application regression; the current commands still use their existing writer. The current standalone increment passed scoped IO/dependent/wasm validation; its separate full CI is running.
For the caller migration, should we preserve the existing accepted domain through an explicitly bounded compatibility contract, or make the stricter admission an agreed user-visible change with its own errors and boundary tests? We are leaving that switch pending and preparing the independent
connectrefactor over hidden lines before entities, preserving its algorithm and ordering. We have not raised limits or added an error-swallowing fallback. The broader numeric-spelling question remains in the existing #5321 coordination question, rather than opening a second numerical-policy thread.The earlier
471e17f5/not-run snapshot above remains historical; the current draft is #8515 atd8e7a869. The proposed adapters and command-test migrations are still private, unapplied and unrun pending review and the current source freeze.feat(dxf): add bounded bulged paths and layered text import (WIP tang…
CamWight commentedon Oct 29, 2026
@0xlillith, good catch on the different budgets. For the caller migration, please keep today's accepted domain: the flat-pattern and current-view exports should accept and write exactly what they do now, through an explicitly bounded compatibility contract. That keeps the migration a pure refactor. The stricter owned-file admission can come afterwards as its own small, named change, with its own errors and boundary tests, so anyone reading the history can see when behaviour changed and why. Agreed on no silent fallback and no raised limits.
The reader notes on #5320 look right to us: no silent try-new-reader route, unsupported records refused explicitly, and the bulged subset reusing the producer's own validator. Nothing to change there.
Drawing export: a sheet of the open drawing as SVG, from its scene (#…
selun3 commentedon Oct 30, 2026
Thanks, Cam. We will keep the current accepted inputs and byte output for the flat-pattern and current-view migration, through an explicitly bounded compatibility contract. No raised limits or silent fallback; stricter admission will remain a separate change with its own errors and boundary tests. We will also retain the reader refusals and the producer's bulged-subset validator as agreed. The pending adapters are still separate from the already validated D8 source.
selun3 commentedon Nov 14, 2026
The fresh #5319 replacement is being validated on the shared converter in #16617. I also checked the layer-weight work in #2968 and Cam’s approval there; our owned-model work does not supersede that contribution.
There is one constructor boundary to keep explicit: #2968’s integer convenience API clamps outside its range and chooses 70 for 75 hundredths, while #5319’s physical-weight constructor refuses values above 2.11 mm and chooses the heavier weight at an exact midpoint (0.75 mm → 80). Both preserve omitted layer weight versus explicit zero.
My proposed composition is one owned model and serializer, with #2968’s layer-facing functionality and attribution retained on that model. I’ll keep the existing #5319 contract while validating; I’m not treating the two constructors as interchangeable or changing the other PR. Cam and @nguyenthanhthe, please flag if you prefer a different integration order. The replacement PR will call out this overlap and link both contributions.
DXF: owned file layers and lineweight model (tangency-labs#5319) (tan…
DXF: layered reader with preserved metadata and shared sketch-import …
claim: tangency-labs#5319
DXF export: Export Current View as DXF puts lines on layer handles, a…
DXF export: Export Current View as DXF puts lines on layer handles, a…