Skip to content

DXF export: the full R2000 file structure strict readers need (#9144) - #9662

Merged
bherbruck merged 2 commits into
tangency-labs:mainfrom
PaddleStroke:fix/9144-dxf-strict-readers
Oct 30, 2026
Merged

bherbruck merged 2 commits into
tangency-labs:mainfrom
PaddleStroke:fix/9144-dxf-strict-readers

Conversation

@PaddleStroke

@PaddleStroke PaddleStroke commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Change

Fixes #9144: AutoCAD 2025 did not recognise a DXF from Export Current View as DXF.

The writer (crates/io/src/dxf_out.rs, shared by the view export and the flat pattern export) declares AutoCAD 2000 (AC1015), but the file left out parts of that release's structure that a strict reader expects. Checked against the public DXF reference and the minimal R2000 content the ezdxf documentation lists, the file was missing:

  • the CLASSES section (may be empty, but must be there);
  • five of the nine symbol tables: VPORT, VIEW, UCS, APPID (with ACAD) and DIMSTYLE (with Standard, whose handle goes under group code 105);
  • the ACAD_GROUP dictionary named by the root dictionary in OBJECTS.

All of those are written now, in the reference's table order, plus $DWGCODEPAGE (ANSI_1252; every character the writer emits is ASCII, other letters are \U+XXXX). The *Active viewport is centred on the drawing's extents with a height that holds all of it, so the drawing opens zoomed to fit rather than on an empty origin. Entities, layers and linetypes are unchanged.

I could not open the file in AutoCAD (no commercial CAD products are used for this project), so the fix brings the file in line with the published structure; the reporter's confirmation would close the loop.

Changes a default: no

Validation

  • New regression test dxf_out::tests::a_strict_reader_finds_every_section_table_and_the_group_dictionary: section order HEADER, CLASSES, TABLES, BLOCKS, ENTITIES, OBJECTS; the nine tables in order, each with as many records as its count says; APPID = ACAD; DIMSTYLE Standard with a 105 handle; *Active centred on (15, 5) for a (0, 0)–(30, 10) drawing and holding it; root dictionary → ACAD_GROUP dictionary owned by the root; every handle (5 and 105) unique and below $HANDSEED; every owner (330) is 0 or a handle in the file; SolidCraft's own reader still reads the entities.

  • cargo test -p solidcraft-io: 196 passed, 0 failed (2 ignored, as before).

  • cargo clippy -p solidcraft-io --all-targets -- -D warnings: clean. cargo fmt --check: clean.

  • Independent check with ezdxf 1.4.5 (MIT, installed in a scratch folder), on a drawing with LINE, LWPOLYLINE, CIRCLE, ARC, ELLIPSE, rational SPLINE and TEXT on VISIBLE / HIDDEN / SKETCH layers. ezdxf's loader silently creates missing tables, so I also checked the raw tags against its documented minimal R2000 content:

    before after
    ezdxf.readfile (strict) OK OK
    recover + audit fixes/errors 0 / 0 0 / 0
    dictionaries ezdxf had to create on load 11, incl. ACAD_GROUP 10 (ACAD_GROUP present)
    raw structure check missing CLASSES; missing tables VPORT, VIEW, UCS, APPID, DIMSTYLE; no ACAD, no Standard dimstyle; no ACAD_GROUP OK (same as an ezdxf-written R2000 file)

Not run: the engine's view/sheet DXF tests (they parse the ENTITIES and LAYER sections, which are unchanged; the engine build is very long on the shared machine), cargo xtask wasm (the change is string writing in solidcraft-io, no new dependencies), and AutoCAD itself.

Screenshots of the behavior (when observable)

No screenshot: nothing changes in the app. The difference is in the file's structure, shown by the table above.

Integration status

Rebased on upstream main at cc9787f; no conflicts. Draft PRs #8435 and #8515 also touch dxf_out.rs (Drawings DXF model); this change only adds sections/tables inside write_dxf_drawing, so a rebase either way should be small.

🤖 Generated with Claude Code

PaddleStroke and others added 2 commits October 30, 2026 21:51
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…angency-labs#9144)

The view and flat pattern DXF left out parts of the AC1015 file that a
strict reader expects: the CLASSES section, the VPORT, VIEW, UCS, APPID
and DIMSTYLE tables (with *Active, ACAD and Standard) and the ACAD_GROUP
dictionary under the root dictionary. They are written now, along with
$DWGCODEPAGE; the active viewport looks at the whole drawing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PaddleStroke
PaddleStroke force-pushed the fix/9144-dxf-strict-readers branch from 914d769 to 0936027 Compare October 30, 2026 21:36
@PaddleStroke
PaddleStroke marked this pull request as ready for review October 30, 2026 21:38
@bherbruck bherbruck added ready to merge reviewed, every ask addressed; merge once CI is green approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) and removed approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) labels Oct 30, 2026
@bherbruck
bherbruck enabled auto-merge October 30, 2026 21:50
@bherbruck bherbruck added approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) and removed approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) labels Oct 30, 2026
@bherbruck
bherbruck added this pull request to the merge queue Oct 30, 2026
Merged via the queue into tangency-labs:main with commit 8d22b3a Oct 30, 2026
112 of 122 checks passed
@PaddleStroke
PaddleStroke deleted the fix/9144-dxf-strict-readers branch November 30, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) ready to merge reviewed, every ask addressed; merge once CI is green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

导出的dxf 文件AUTOCAD2025不识别

2 participants