Skip to content

fix(tables): decode R14 DIMSTYLE with §20.4.68's R13/R14 block (#74) - #297

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

DrunkOnJava merged 3 commits into
mainfrom
fix/74-dimstyle-r14

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Decode R14 DIMSTYLE with the "R13 & R14 Only" block that §20.4.68 prints. The dispatcher reported every R14 DIMSTYLE as unhandled because the order had never been measured. All 20 R14 DIMSTYLE records of the public corpus now close on their RL boundary. Their values equal the R2000 saves of the same drawings, handle for handle, and the spec's own §20.4.68.1 example closes as well. With #293 this leaves no table entry of the 52-file corpus skipped or erroring.

Closes #74.

Spec reference

§20.4.68 DIMSTYLE, R13 & R14 Only. After the common entry header come:

  • 11 flag Bs: DIMTOL, DIMLIM, DIMTIH, DIMTOH, DIMSE1, DIMSE2, DIMALT, DIMTOFL, DIMSAH, DIMTIX, DIMSOXD.
  • RC DIMALTD and RC DIMZIN, then B DIMSD1 and B DIMSD2.
  • RC DIMTOLJ, DIMJUST and DIMFIT, B DIMUPT, then RC DIMTZIN, DIMALTZ, DIMALTTZ and DIMTAD.
  • Six BS unit and precision fields.
  • 17 BDs, DIMSCALE through DIMGAP.
  • Five T strings: DIMPOST, DIMAPOST, DIMBLK, DIMBLK1 and DIMBLK2.
  • Three BS colours: DIMCLRD, DIMCLRE and DIMCLRT.

The B that §20.4.68 lists as common after DIMLWE ("Seems to set the 0-bit (1) of the 70-group") follows. decode_r2000_inline and the R2007+ reader already read that bit on their releases.

Measured

Check Result
RL boundary of the common object data all 20 R14 records close: 6 in ACadSharp's sample_AC1014.dwg (0x27, 0xE1, 0x39A, 0x994, 0xB06, 0xC88), and 2 in each of the 7 nextgis R14 drawings
Without the trailing B the records fail the check; 0x27 ends at bit 848 against a boundary of 849
The 15 surfaced fields against the R2000 save, handle for handle 20 / 20 equal. The only difference is the name's case: R14 stores STANDARD, ANNOTATIVE and CUSTOM_DIM_STYLE where R2000 has Standard, Annotative and custom_dim_style
§20.4.68.1, the spec's R14 example (STANDARD, handle 1D) closes. spec_examples --update flips r14-objects.tsv from unhandled to closes

For example, BESCHRIFTUNG 0xB06 decodes on R14 to dimscale 0, dimasz 2.5, dimexo 0.625, dimexe 1.25, dimtxt 2.5, dimcen 2.5, dimtad 1 and dimaltf 1/25.4. Those are the same values as Beschriftung on R2000, and the same as the overrides AutoCAD's DXF export of the R2007 save writes for 0xB06 (groups 40, 41, 42, 44, 77, 140, 141, 143).

DIMALTRND has no slot in the R13/R14 block, so DimStyleEntry::dimaltrnd is 0 there.

C=~/Library/Caches/dwg-corpus
for f in $C/acadsharp/sample_AC1014.dwg $C/nextgis/*_R14.dwg; do cargo run --release --example probe_decode_errors -- $f DIMSTYLE; done   # 0 erroring each
cargo run --release --example spec_examples                                                                                              # §20.4.68 closes
cargo run --release --example probe_dimstyle_r14 -- $C/acadsharp/sample_AC1014.dwg $C/acadsharp/sample_AC1015.dwg                       # 6 equal
for n in arc circle ellipse line point2d point3d polyline2d_line; do cargo run --release --example probe_dimstyle_r14 -- $C/nextgis/${n}_R14.dwg $C/nextgis/${n}_2000.dwg; done   # 2 equal each

examples/probe_dimstyle_r14.rs (new) matches each R14 DIMSTYLE by handle to the R2000 save's record. It compares the fifteen surfaced fields, with names compared case-insensitively, and exits non-zero on a difference, an unpaired handle or an undecoded record. All eight pairs end RESULT: every R14 DIMSTYLE equals its R2000 save.

Coverage, ../../samples

TOTAL 4256 / 180 / 9 → 4262 / 174 / 9. The three nextgis R14 drawings among the 19 files each gain their 2 DIMSTYLE records.

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

sample_AC1014.dwg          1019 119 104  →  1025 113 104
arc_R14.dwg                 281  11   0  →   283   9   0
circle_R14.dwg              281  11   0  →   283   9   0
ellipse_R14.dwg             294  11   0  →   296   9   0
line_R14.dwg                281  11   0  →   283   9   0
point2d_R14.dwg             280  11   0  →   282   9   0
point3d_R14.dwg             280  11   0  →   282   9   0
polyline2d_line_R14.dwg     280  12   0  →   282  10   0

52-file total: 14938 / 831 / 305 → 14958 / 811 / 305, measured against main at f44d92d. measure.py check passes.

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: one cell, §20.4.68 unhandled → closes
  • No unit tests added or changed.

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.68 of the ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1), including its worked example, and on the corpus bytes (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.

The dispatcher reported every R14 DIMSTYLE as unhandled because the
R13/R14 layout had never been measured. Read the block §20.4.68 prints
(flags, RC settings, BS units, BD reals, five T strings, three BS
colours) and the common trailing B. All 20 R14 records of the public
corpus close on their RL boundary, their values equal the R2000 saves of
the same drawings handle for handle, and the spec's own §20.4.68.1
example now 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 ✅ Completed 2026-10-26T17:51:03.528494Z fbc1115 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

Copy link
Copy Markdown
Owner Author

Merge-train note for fbc1115: main had changed these docs/data/spec-coverage.tsv notes since this PR's base, and this PR rewrote them too. The PR's free text was kept and main's was dropped. Tool-written sentences (DXF oracle, spec examples) were kept and regenerated. Check that nothing below still needs saying:

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.

R14 DIMSTYLE block order (§20.4.68) unmeasured — 6 records

1 participant