Skip to content

fix(objects): LAYOUT has no data-store block; those 16 bits are plot_layout_flags - #236

Merged
DrunkOnJava merged 2 commits into
mainfrom
fix/layout-plot-flags
Oct 26, 2026
Merged

DrunkOnJava merged 2 commits into
mainfrom
fix/layout-plot-flags

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

LAYOUT has no "R2013+ data-store block": the 16 bits objects::acad_layout read after the common object data's has AcDs binary data bit are the first 16 of plot_layout_flags in its full BS form. Reading nothing there gives the plot-layout flags AutoCAD exports, on all nine records the DXF value oracle pairs.

Spec reference

§20.4.84 LAYOUT (plot-settings block: BS plot layout flags 70 first) and §2.2 BS (code 00 + RS); §20.1 common object data (B has_ds_binary_data, R2013+).

Both readings close on the data-stream boundary, because a BS of 256 or more is 00 + 16 bits = 18 bits, exactly the old 16-bit "block" plus a 10 (value 0) BS. The boundary cannot separate them; AutoCAD's DXF export of the same drawing can:

Record DXF 70 Full-form BS Old reading Old plot_layout_flags
Model, handle 22 (sample_AC1032, sample_AC1027, geoloc) 11952 = 0x2EB0 00 B0 2E RC 0x2C, RC 0x0B, BS 10 0
paper layouts 59, 5E, 25A (both samples) 688 = 0x02B0 00 B0 02 RC 0x2C, RC 0x00, BS 10 0

The 0x2C / 0x0B / 0x00 bytes the module docs recorded as the block are exactly these bits. The flag is followed by no bits on objects, as on the three ACIS entities that set it (#61). AcadLayout::ds_block and the crate-internal ObjectStream::has_ds_binary_data are removed; module docs, a dated ARCHITECTURE.md section with the table above, and STATUS.md say what changed.

Test plan

  • cargo fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings, RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
  • cargo test --release --all-features with the 19-file ../../samples corpus present: all pass, no test added
  • Coverage unchanged (the two readings consume the same bits): cargo run --release --example coverage_report -- <dir> gives TOTAL 3911 525 9 88.0 on the 19-file corpus and 6438 885 308 84.4 on the ACadSharp samples, before and after
  • Values, with the DXF value oracle (examples/dxf_oracle, the pairing/scorer example that follows feat(dxf): an ASCII DXF reader keyed by handle, for the value oracle #223) over nextgis ff05d5a8 and ACadSharp samples/ c30a97ce (the pinned set of ci(corpus): measure the reader on public drawings fetched by pinned hash #225):
cargo run --release --features dxf-reader --example dxf_oracle -- <corpus-dir>

Before (main), the LAYOUT table's row:

  field                                    group            R14   R2000   R2004   R2007   R2010   R2013   R2018   total
  plot_layout_flags                        70                                 =               =   ≠4/25    ≠5/7   73/0/9/0
  geoloc.dwg                  22 LAYOUT         plot_layout_flags                  70         DWG 0  DXF 11952
  sample_AC1027.dwg           59 LAYOUT         plot_layout_flags                  70         DWG 0  DXF 688

After (this branch): plot_layout_flags 70 = = = = 82/0/0/0, and every other LAYOUT field stays = on every release (82 records). R2000 and R2007 LAYOUTs are not decoded (custom class, unchanged).

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.

Based on ODA spec v5.4.1 §2.2, §20.1 and §20.4.84, and AutoCAD's own DXF exports in nextgis/dwg_samples and the ACadSharp samples/ directory, read as data. No permissively-licensed project's 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.

Refs #99

…layout_flags

On the R2013 and R2018 LAYOUT records that set the common object data's
has AcDs binary data bit, objects::acad_layout read 16 bits after it as
a data-store block and then plot_layout_flags as a 2-bit BS of 0. Both
that reading and reading nothing close on the boundary: a BS whose value
needs 16 bits is the code 00 and an RS, the same 18 bits. AutoCAD's DXF
export of the same drawings settles it. Group 70 of the plot settings is
688 (0x02B0) on every paper layout and 11952 (0x2EB0) on Model, which
is what the full-form BS decodes to; the old reading gave 0 on all nine
records the DXF value oracle pairs. The bytes match bit for bit:
00 + B0 02 is 0x2C, 0x00 and a 10 code; 00 + B0 2E is 0x2C, 0x0B, 10.

The flag is followed by no bits on objects, as on the ACIS entities
that set it. AcadLayout::ds_block and ObjectStream::has_ds_binary_data
are removed; the module docs, ARCHITECTURE.md (dated section with the
evidence table) and STATUS.md say what changed. Coverage is unchanged.

Refs #99
@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 ✅ Completed 2026-10-26T10:32:19.459721Z 909f17e 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.

@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 26, 2026 10:31
@DrunkOnJava
DrunkOnJava merged commit 2353efb into main Oct 26, 2026
25 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/layout-plot-flags branch October 26, 2026 10:52
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