Skip to content

fix(tables): read the BL reactor count in the R2007+ table-entry prefix (#40) - #293

Merged
DrunkOnJava merged 3 commits into
mainfrom
fix/228-dimstyle
Oct 26, 2026
Merged

DrunkOnJava merged 3 commits into
mainfrom
fix/228-dimstyle

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Read the BL num_reactors that §20.4.x prints in every table entry's common data. tables::modern, the R2007+ path, skipped it and compensated in two ways: a flag order that changed with the release, and on R2013+ an RC after a set binary-data bit. On entries with no reactors the shifted reads used the same bits, so the records closed, but with the xdictionary bit in their 64-flag. On entries with reactors they failed: the six R2007/R2010 DIMSTYLE errors #228 lists. They now close, and every value the new probe compares equals AutoCAD's DXF export.

Closes #40. Closes #35. Part of #228 (DIMSTYLE; HATCH is next, VIEW belongs to the oracle lane). Opens #290 for the one question the corpus can't answer.

Spec reference

§20.4.x common table-entry data (for example §20.4.54 LAYER, p. 161), R2000+: EED, BL Numreactors, B XDic Missing Flag (R2004+), plus the §20.1 B for AcDs binary data (R2013+). Then TV name, B 64-flag, BS xrefindex+1, B Xdep.

skip_object_prefix now reads that prefix, which objects::modern reads for every other non-entity object, and reads no RC after the binary-data bit. From R2007 the name is in the string stream and two bits remain on every table entry, so read_entry_flags reads them as B 64-flag, B Xdep and returns xrefindex+1 as 0.

What the old reading took each bit for:

Release Bits after the EED Old reading Now
R2007, R2010 1 0 xdictionary-missing, Xdep BL 0
next 64-flag xdictionary-missing
1 0 BS xrefindex+1 0 64-flag, Xdep
R2013, R2018 1 0 xdictionary-missing, binary data BL 0
next two 64-flag, Xdep xdictionary-missing, binary data
1 0 BS xrefindex+1 0 64-flag, Xdep

A reactor count above 0 is the code 01 plus a byte. On R2013+ the old reading took the 01 for its two flags and the byte for its RC; that is where the "8 more bits after the AcDs flag" in ARCHITECTURE §7a came from (8 and 2 are the reactor counts). On R2007/R2010 nothing absorbed the byte, so the three DIMSTYLE records with reactors failed: ISO-25 0x39A with 8, custom_dim_style 0x994 with 2, and custom_style_ltypes 0xC88 with 1.

Every table entry of the 52 drawings

Each table entry of every pinned drawing, decoded through entities::decode_from_raw (closed on its data-stream boundary). "skipped" means the dispatcher has no decoder for the record:

Table R14 R2000 R2004 R2007 R2010 R2013 R2018
APPID 84 82 82 70 62 60 62
BLOCK_HEADER 48 48 48 48 48 48 43
DIMSTYLE 0 + 20 skipped 20 20 20 20 20 12
LAYER 28 28 28 28 26 26 24
LTYPE 29 29 29 29 29 29 62
STYLE 20 20 20 20 20 20 13
VIEW 1 1 1 1 1 1 1
VPORT 8 8 8 8 8 8 4
All 218 + 20 skipped 236 236 224 214 212 221

On main the R2007 and R2010 DIMSTYLE cells read 17 + 3 err. Every R2000-R2018 table entry now closes. The 20 R14 DIMSTYLE records are skipped: the dispatcher has no R13/R14 DIMSTYLE decoder yet (#74), and this PR does not touch that path.

Measured against AutoCAD's DXF

examples/probe_table_prefix.rs (new) reads the prefix and flags of every table entry and matches each one by handle to the twin's record. Over the 32 R2000-R2018 drawings of the public corpus that have a twin there are 1,078 table entries, 1,020 of them with a twin record:

Compared Agree Differ
BL num_reactors = the 330s in {ACAD_REACTORS (18 non-zero) 1,020 0
R2004+ xdictionary-missing = no {ACAD_XDICTIONARY (53 present) 840 0
Xdep = bit 16 of group 70 (BLOCK_RECORD excluded: its 70 is insertion units) 786 0
R2000/R2004 inline name = group 2 360 0

The xdictionary bit sits two bits after the BL, so its agreement on all 53 entries that have an xdictionary pins the BL's position independently of the reactor counts. Three twins carry an xdictionary the drawing doesn't have. LTYPE GAS_LINE 0x6B2 in the R2004, R2007 and R2010 exports points at dictionary 0x1455, an ACAD_XREC_ROUNDTRIP holding an ACAD_ROUNDTRIP_2011_LINETYPE xrecord. That dictionary isn't an object of those DWGs and isn't in the R2013 export, so the export adds it when writing an older release. The DWG bit says "missing" on all three, and the probe counts them apart rather than as differences.

All 676 R2007-R2018 entries read the two flag bits as 1, 0. All 402 R2000/R2004 entries read 64-flag set, xrefindex+1 0 and Xdep clear. That settles #35's labelling question for the inline path: if the first inline bit were Xdep it would be set on all 402 entries, and group 70 bit 16 is clear on every one. For R2007+ the export rules out the swapped order the same way. A lone BS xrefindex+1 of 0, though, is the same two bits 1 0, and neither corpus has an xref-dependent entry to tell them apart. That is #290.

The six DIMSTYLE records decode to the same values on R2004, R2007, R2010, R2013 and R2018, in all fifteen fields DimStyleEntry surfaces. ISO-25's ten non-default groups in the R2007 export (41 2.5, 42 0.625, 44 1.25, 73 0, 74 0, 77 1, 140 2.5, 141 2.5, 143 0.03937007874016, 283 0) equal the decoded values. The styles the export writes no overrides for decode to the defaults.

C=~/Library/Caches/dwg-corpus
for v in 1015 1018 1021 1024 1027 1032; do cargo run --release --example probe_table_prefix -- $C/acadsharp/sample_AC$v.dwg $C/acadsharp/sample_AC${v}_ascii.dxf; done
cargo run --release --example probe_table_prefix -- $C/acadsharp/geoloc.dwg $C/acadsharp/geoloc.dxf
for n in arc circle ellipse line point2d; do for v in 2000 2004 2007 2010 2013; do cargo run --release --example probe_table_prefix -- $C/nextgis/${n}_$v.dwg $C/nextgis/${n}_$v.dxf; done; done

Each run ends RESULT: every compared value equals the twin, and the probe exits non-zero on any difference.

Values change on decoded records too: R2007+ entries that have an xdictionary used to report flag_64 = false, and now report true, as their R2000/R2004 saves do. Any oracle score of the table flags (#248/#277) moves with that.

Coverage, ../../samples

Unchanged, TOTAL 4256 / 180 / 9. The two reactor-bearing DIMSTYLEs of sample_AC1032.dwg closed before through the RC, and the nextgis drawings' table entries have no reactors.

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

sample_AC1021.dwg   834 76 15  →  837 76 12
sample_AC1024.dwg   851 57 15  →  854 57 12

52-file total: 14938 / 831 / 305 → 14944 / 831 / 299. Measured against main at 59154b4. #283 (ACIS) moves the same two rows by 3 decoded each, for different records, and both apply; the merge train regenerates the baseline. measure.py check passes. The spec worked examples (spec_examples --update) are unchanged, since they are R14 records on the inline path.

Class census and reference closure

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

Docs

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
  • cargo run --release --example spec_examples -- --update leaves the fixtures unchanged
  • Adds no unit tests; adapts 9 existing test helpers and 1 assertion. The R2007+ body builders in appid, block_record, dimstyle, layer, ltype, style, ucs, view and vport tests wrote the disproven prefix (B, B, B, B, BS). They now write the measured one: BL 0, then xdictionary, binary data, 64-flag and Xdep bits, with no BS. Only block_record's failed, because it wrote BS 1. The other eight wrote BS 0, which happens to be the same bits. block_record::tests::r2007_split_stream_block_record_reads_name_from_string_stream asserted xref_index_plus_1 == 1, which came from that BS. It now asserts 0.

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.1 and the §20.4.x table sections of the ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1), including their DXF group codes. It also uses the corpus bytes and AutoCAD's DXF exports of the same drawings, read as data files (ACadSharp samples/ at c30a97ce, MIT, and nextgis/dwg_samples, pinned by #225). 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.

…ix (#40)

tables::modern skipped the BL num_reactors that §20.4.x prints and
objects::modern reads, and compensated with a release-dependent flag
order and an RC after the R2013+ binary-data bit. With no reactors the
shifted reads consumed the same bits, so records closed with the
xdictionary bit in their 64-flag; with reactors the six R2007/R2010
DIMSTYLE records failed. Read the BL, drop the RC, and read the two
bits that remain as B 64-flag, B Xdep.

examples/probe_table_prefix.rs compares the prefix with AutoCAD's DXF
export: reactor counts, xdictionary bits, Xdep and inline names agree
on every table entry of the 32 R2000-R2018 drawings with a twin.
@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-26T17:23:13.177260Z 88113a7 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 enabled auto-merge (squash) October 26, 2026 17:24
@DrunkOnJava
DrunkOnJava merged commit f3081d9 into main Oct 26, 2026
26 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/228-dimstyle branch October 26, 2026 17:30
DrunkOnJava added a commit that referenced this pull request Oct 26, 2026
Three more types are compared field by field with AutoCAD's export:
MLEADERSTYLE (§20.4.87) and VIEW (§20.4.60) against their spec's DXF
column, and VISUALSTYLE, which v5.4.1 does not prescribe, against the
DXF Reference's group for each named property.

On the 49 drawing pairs: MLEADERSTYLE's 49 records R2000-R2018 agree on
every decoded value (1914 equal, 36 by the DXF default). VISUALSTYLE's
1,008 records agree on 58,104 values and disagree on 264, all filed on
issue 250: format_version on R2013 and R2018 (DWG 2, export 3) and
Realistic's face lighting quality on R2000-R2007 (DWG 2, export 3).
VIEW's 6 records agree on every decoded value (120 equal), the R2013 and
R2018 Xdep bit included since #293. Before #251 and #253 these scorers
found 1,440 VISUALSTYLE values and MLEADERSTYLE's two swapped flags
wrong.

tools/oracle/baseline.tsv gains the 789 new rows; VIEW and MLEADERSTYLE
in docs/spec-coverage.md say what was measured, and VIEW no longer lists
the pre-R2007 errors #263 fixed. CLEANROOM records the scorers' sources.

Refs #99, #102, #250, #256
DrunkOnJava added a commit that referenced this pull request Oct 26, 2026
…le (#279)

Three more types are compared field by field with AutoCAD's export:
MLEADERSTYLE (§20.4.87) and VIEW (§20.4.60) against their spec's DXF
column, and VISUALSTYLE, which v5.4.1 does not prescribe, against the
DXF Reference's group for each named property.

On the 49 drawing pairs: MLEADERSTYLE's 49 records R2000-R2018 agree on
every decoded value (1914 equal, 36 by the DXF default). VISUALSTYLE's
1,008 records agree on 58,104 values and disagree on 264, all filed on
issue 250: format_version on R2013 and R2018 (DWG 2, export 3) and
Realistic's face lighting quality on R2000-R2007 (DWG 2, export 3).
VIEW's 6 records agree on every decoded value (120 equal), the R2013 and
R2018 Xdep bit included since #293. Before #251 and #253 these scorers
found 1,440 VISUALSTYLE values and MLEADERSTYLE's two swapped flags
wrong.

tools/oracle/baseline.tsv gains the 789 new rows; VIEW and MLEADERSTYLE
in docs/spec-coverage.md say what was measured, and VIEW no longer lists
the pre-R2007 errors #263 fixed. CLEANROOM records the scorers' sources.

Refs #99, #102, #250, #256
DrunkOnJava added a commit that referenced this pull request Oct 26, 2026
§20.4.60 stores VIEW's view mode as four bits, "0: 71's bit 0 (1), 1:
71's bit 1 (2), 2: 71's bit 2 (4), 3: OPPOSITE of 71's bit 4 (16)", and
notes that bit 3 (8) of group 71 "can not be specified". Both VIEW paths
surfaced the raw bits; they now surface the group-71 value through the
conversion VPORT uses (§20.4.64, #238), with no UCSFOLLOW bit.

The DXF value oracle compares ViewEntry::view_mode with group 71
directly now, instead of converting the stored bits in its scorer: equal
on all 6 VIEW records, R2000 to R2018. Its baseline row is renamed from
"view_mode (stored bits, as group 71)" to "view_mode". The two VIEW
round-trip tests write the bits 0001, whose group-71 value is 0.

Closes #256 (with #263, #279 and #293, every decoded VIEW value now equals the export).
DrunkOnJava added a commit that referenced this pull request Oct 26, 2026
§20.4.60 stores VIEW's view mode as four bits, "0: 71's bit 0 (1), 1:
71's bit 1 (2), 2: 71's bit 2 (4), 3: OPPOSITE of 71's bit 4 (16)", and
notes that bit 3 (8) of group 71 "can not be specified". Both VIEW paths
surfaced the raw bits; they now surface the group-71 value through the
conversion VPORT uses (§20.4.64, #238), with no UCSFOLLOW bit.

The DXF value oracle compares ViewEntry::view_mode with group 71
directly now, instead of converting the stored bits in its scorer: equal
on all 6 VIEW records, R2000 to R2018. Its baseline row is renamed from
"view_mode (stored bits, as group 71)" to "view_mode". The two VIEW
round-trip tests write the bits 0001, whose group-71 value is 0.

Closes #256 (with #263, #279 and #293, every decoded VIEW value now equals the export).
DrunkOnJava added a commit that referenced this pull request Oct 28, 2026
…d say what measured them (#140, #147, #148, #133, #127) (#398)

Seven rows leave partial for closes because no record of any kind errors on the
52 drawings of run 40532346172 and the errors their notes still quote were
fixed: TEXT, ATTRIB, ATTDEF (#258), MTEXT (#261), VIEW (#263, #284), DIMSTYLE
(#293) and HATCH (#264, the R14 records routed). §22 AcDb:Template goes from
missing to partial: dxf_header reads $MEASUREMENT from it (#320). §9 stays
closes, now tracked by #127 (R13) and carrying the per-release evidence behind
closing #128, #129 and #130. The page's Last measured line and the paragraph
that said closes came from a local 19-file corpus are updated.
DrunkOnJava added a commit that referenced this pull request Oct 28, 2026
…ain run (#195) (#401)

* docs(spec-coverage): move the rows the 2026-10-27 main run proves, and say what measured them (#140, #147, #148, #133, #127)

Seven rows leave partial for closes because no record of any kind errors on the
52 drawings of run 40532346172 and the errors their notes still quote were
fixed: TEXT, ATTRIB, ATTDEF (#258), MTEXT (#261), VIEW (#263, #284), DIMSTYLE
(#293) and HATCH (#264, the R14 records routed). §22 AcDb:Template goes from
missing to partial: dxf_header reads $MEASUREMENT from it (#320). §9 stays
closes, now tracked by #127 (R13) and carrying the per-release evidence behind
closing #128, #129 and #130. The page's Last measured line and the paragraph
that said closes came from a local 19-file corpus are updated.

* docs(criteria): re-measure the 1.0 requirements from the 2026-10-27 main run (#195)

Header, R2, R3, R4, R8, X1 and S3 now carry what run 40542129639 (main 61255e9)
and docs/data/spec-coverage.tsv say: 52 drawings with 0 errored records and 533
skipped, 53 sections scored by the DXF oracle with 22 values disagreeing, 90
closes, 13 partial, 6 decoder and 29 missing rows, a wasm32 compile of the
library in the Clippy job. X1 (DXF) moves from not measured to failed: the HEADER,
TABLES, ENTITIES and BLOCKS probes pair the written records with AutoCAD's export
and find 0 groups disagreeing, and 342 entity records of 18 kinds and the OBJECTS
section are not written. No other status changes.

* docs(criteria): R3 counts the rows #398 moves: 97 closes, 7 partial, 6 decoder, 28 missing (#195)

The counts are those of docs/data/spec-coverage.tsv with #398, whose moves run
40532346172 proves.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant