Skip to content

fix(objects): decode LAYOUT on R14, R2000 and R2007 with §20.4.84's version branches (#229) - #270

Merged
DrunkOnJava merged 3 commits into
mainfrom
fix/229-layout
Oct 26, 2026
Merged

DrunkOnJava merged 3 commits into
mainfrom
fix/229-layout

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

Decode LAYOUT (and the PLOTSETTINGS block it embeds) on R14, R2000 and R2007. This PR reads §20.4.84's R13-R2000 and R2004+ branches, routes the R14/R2000 class number, and drops the stale R2007 refusal. All 75 LAYOUT records of the public corpus that were skipped now close, and every one equals the R2004 save of the same drawing, handle by handle. Part of #229.

Spec reference

§20.4.84 LAYOUT (varies) has three branches the decoder refused instead of reading:

Branch Field
R13-R2000 Only T plot view name (6), after the plot window
R2004+ BS shade plot mode, resolution level and custom DPI (76-78)
R2004+ viewport count (measured BL, §7d.2)

R2007 was refused on the grounds that its string stream could not be located, which #65 fixed. On R14 and R2000 LAYOUT has a class number from AcDb:Classes rather than 0x52, so this PR also adds a LAYOUT arm to dispatch_object_class. check_version is removed. AcadPlotSettings gains plot_view_name (empty from R2004). The shade-plot fields and viewport_count read 0 where the record does not store them, and the docs say so.

Records it was measured on

R14 and R2000 have no DXF twin in the corpus; R2007 does, but the comparison here is against R2004. examples/probe_cross_release.rs (#264, which merges first) compares each record with the R2004 save of the same drawing, the band whose list §7d.2 measured, ignoring only fields a release does not store:

Release Records Close Equal to the R2004 save
R14 (7 nextgis × 3, ACadSharp 4) 25 25 25
R2000 25 25 25
R2007 25 25 25 (ignoring only trailing_strings, the string-stream residue)

On R14 and R2000 the comparison ignores the shade-plot fields and viewport_count. They are also compared with the plot view name included: it is empty on every record and equal, so it is measured only as an empty TV.

C=~/Library/Caches/dwg-corpus
for n in arc circle ellipse line point2d point3d polyline2d_line; do for v in R14 2000; do
  cargo run --release --example probe_cross_release -- $C/nextgis/${n}_$v.dwg $C/nextgis/${n}_2004.dwg LAYOUT \
    --ignore=plot_view_name,shade_plot_mode,shade_plot_resolution_level,shade_plot_custom_dpi,viewport_count,trailing_strings
done; cargo run --release --example probe_cross_release -- $C/nextgis/${n}_2007.dwg $C/nextgis/${n}_2004.dwg LAYOUT --ignore=trailing_strings; done

Coverage, ../../samples

cargo run --release --example coverage_report -- ../../samples:

                    before                    after
each *_R14.dwg     166 126 0  56.8 %         169 123 0  57.9 %
each *_2000.dwg    202   9 0  95.7 %         205   6 0  97.2 %
each *_2007.dwg    178   8 0  95.7 %         181   5 0  97.3 %
TOTAL             3911 525 9  88.0 %        3938 498 9  88.6 %

Public corpus: tools/corpus/baseline.tsv (regenerated, committed)

Twenty-four rows move: every R14, R2000 and R2007 drawing gains 3 decoded and loses 3 skipped (4 for ACadSharp's). The 52-file total goes from 13781 / 1985 / 308 to 13856 / 1910 / 308. measure.py check passes. The R14 rows overlap #254, #264 and #267, so this is regenerated in the serial rebase.

Class census and reference closure

Unchanged on all 19 files of ../../samples and in the baseline's census and closure columns.

Docs

  • docs/data/spec-coverage.tsv §20.4.84 → closes; docs/spec-coverage.md regenerated.
  • ARCHITECTURE.md: new §7s. The version tables in acad_layout.rs and acad_plot_settings.rs are updated.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • RUSTFLAGS="-D warnings" cargo test --release --all-features (real-file tests ran against ../../samples)
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
  • tools/corpus/measure.py check passes against the committed baseline
  • Removes 3 existing unit tests; adds none. acad_layout::tests::rejects_the_undetermined_release_bands and acad_plot_settings::tests::rejects_the_undetermined_release_bands asserted that R14, R2000 and R2007 are refused. entities::dispatch::tests::undetermined_layout_release_is_unhandled_not_error asserted that an R2000 LAYOUT comes back Unhandled as undetermined. The corpus disproves that: all 75 records of those bands now close and equal their R2004 saves.

Source-provenance declaration

By submitting this PR I certify that my contribution does not incorporate executable code from any source whose license is incompatible with Apache-2.0. Specifically:

  • No Autodesk DWG SDK source (RealDWG, ObjectARX, ObjectDBX) or NDA-protected Autodesk documentation was consulted or imported.
  • No Open Design Alliance Teigha / Drawings SDK source was consulted or imported. The ODA's public Open Design Specification for .dwg files PDF is explicitly allowed (see CLEANROOM.md).
  • No GPL-licensed DWG implementation source (LibreDWG, etc.) was consulted or imported.

My contribution is based on §20.4.84 of the ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1) and on the corpus bytes. No third-party code or comments were read.

Developer Certificate of Origin

By submitting this PR, I certify that the contribution complies with the Developer Certificate of Origin 1.1.

…ersion branches (#229)

§20.4.84 gives LAYOUT and its plot-settings block a TV plot view name
on R13-R2000 and the shade-plot fields and viewport count from R2004;
the decoder refused those bands instead of reading them, R2007 on the
stale ground that its string stream could not be located, and on R14
and R2000 LAYOUT carries a class number dispatch never routed. All 75
R14, R2000 and R2007 LAYOUT records of the public corpus were skipped.

Read as printed and routed by class name, all 75 close, and each equals
the R2004 save of the same drawing handle by handle, apart from the
fields a release does not store. The three unit tests that pinned the
refusal are removed. ARCHITECTURE.md §7s records it; §20.4.84 moves to
closes.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-26T13:38:34.125377Z a50b09f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

# Conflicts:
#	ARCHITECTURE.md
#	docs/data/spec-coverage.tsv
#	docs/spec-coverage.md
#	tools/corpus/baseline.tsv
@DrunkOnJava
DrunkOnJava merged commit 33940ea into main Oct 26, 2026
26 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/229-layout branch October 26, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant