Repository navigation
DWG: AutoCAD 2027's materials kept through DWG; its test drawings on main - #29
Merged
Merged
Conversation
The AutoCAD 2027 test drawings of the 3D work (crates/io/tests/data/ acad-solids, 50 drawings and their two READMEs) are DWG and DXF reference files for main's DWG and DXF work as well. Copied unchanged from the 3D branch, with their ATTRIBUTION.md rows in the same place, so merging main into 3D sees the same change on both sides. The tests that use them for 3D stay on the 3D branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RstRyPmyUTMJji65UEF
The MATERIAL codec held AutoCAD's default materials as fixed bit runs taken from an older AutoCAD's files, whose maps have the scene as their source. AutoCAD 2027 gives each map an image file as its source (with no file named) and its own channels (63), so its DWG materials were not decoded (lost on opening) and its DXF ones, which give a group only when the value is not the default, were not encoded (lost on saving as DWG): ByLayer, ByBlock and Global, in every drawing. The record is now read and written by its fields: each map's blend, projection, tiling, automatic transform, matrix, then its source and, for an image file, the file; from 2007 the channels. A group the DXF leaves out holds AutoCAD's default (source 1, the identity, 127 channels), and decoding leaves the defaults out as AutoCAD's DXF does. Every other field must be AutoCAD's default, or the material is left out and counted, as before. Every material record of AutoCAD 2027's and of mi201's DWG files (2000 to 2018) is accounted for bit by bit. Tests: the codec writes AutoCAD 2027's ByLayer record bit for bit (2000 and 2018) and reads it back; materials keep their groups through every version; a material it can't hold is an error both ways. AutoCAD 2027's DWG files read as its DXF gives them, and its DXF saved as DWG of every version reads back the same (both fail without the fix). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RstRyPmyUTMJji65UEF
Clippy 1.97 refuses `d < x || d > y` in `same_angle`. Its suggestion would make a NaN angle compare equal; the distance to the nearest full turn keeps the old result for every input. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RstRyPmyUTMJji65UEF
withshalom
pushed a commit
that referenced
this pull request
Nov 18, 2026
For Codie: the 22 strict-roundtrip findings left after the MATERIAL fix (#29): MESH, the surfaces, AutoCAD's solid-history (ACSH_*), persistent-subentity managers and associative (ACDBASSOC*) objects. What happens to them now (left out and counted, never a crash, lost on DWG open as well as on DXF -> DWG save), where the work goes (main, per the owner's decision and AGENTS.md), the method that found the MATERIAL layout, an order to take them in, and two related gaps on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RstRyPmyUTMJji65UEF
withshalom
marked this pull request as ready for review
November 18, 2026 19:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
draftcraft-cli roundtripin strict mode, run on AutoCAD 2027's test drawings (crates/io/tests/data/acad-solids), reported 3 MATERIAL objects "lost on save, not written" for DXF → DWG in almost every file. The same three materials (ByLayer, ByBlock, Global) are in every drawing AutoCAD makes, 2D included. Two problems:94 63. The encoder only accepted the longer form an older AutoCAD wrote (72 0…, all six matrices), so it gave up.$CMATERIALwas lost. The roundtrip's DWG → DWG route only showed nothing lost on save because the materials never reached the writer.The fix
crates/dwg/src/read/styles.rs: the MATERIAL record is now read and written field by field. Each map is its blend, projection, tiling, automatic transform and matrix, then its source and, for an image file, the file; from 2007 the channels follow. AutoCAD 2027 gives each map an image file as its source (with no file named) and channels 63; the older AutoCAD used the scene (0) and 127.The test drawings on main
The
acad-solidsdrawings (50 DWG/DXF files and their two READMEs) are copied unchanged from the3Dbranch. TheirATTRIBUTION.mdrows sit in the same place, so merging main into3Dsees the same change on both sides. Only DWG/DXF tests use them here; the 3D tests stay on3D.Tests
styles.rs): writes AutoCAD 2027's ByLayer record bit for bit (2000 and 2018) and reads it back. Materials keep their groups through every version. A material the codec can't hold is an error both ways.crates/io/tests/it/style_objects_dwg.rs: AutoCAD 2027's DWG files read their materials as its DXF of that version gives them, and its DXF saved as DWG of every version reads back the same. Both tests fail without the fix.acad-solids: 29 findings → 22, none of them MATERIAL. The rest (MESH, the surfaces,ACSH_*,ACDB*PERSSUBENTMANAGER,ACDBASSOC*) are left out and counted, never a crash; they're written up for the 3D work.Also
crates/engine/tests/it/arc_ctrl_direction.rs: clippy 1.97 refusesd < x || d > y(manual_range_contains). Its suggested fix would change the result for a NaN angle, so the line uses an equivalent form instead.Checks
cargo xtask ci: fmt, clippy, i18n, assets, layers and wasm pass, and the full test suite passes exceptgpu_viewport_stencil::clipped_viewport_contents_draw_only_inside_their_outline, which needs a graphics adapter the container doesn't have ("No adapter found").Not in this PR (found along the way)
object_tagsincrates/io/src/dwg/carry.rs). For example, the Global material'sACADdata is in AutoCAD's DWG and in DraftCraft's, but not in the drawing either opens to.$CMATERIALpoints at nothing and is lost.Generated by Claude Code