Skip to content

feat(dxf): write the CLASSES section from the class table (#126) - #368

Merged
DrunkOnJava merged 5 commits into
mainfrom
feat/dxf-classes
Oct 27, 2026
Merged

DrunkOnJava merged 5 commits into
mainfrom
feat/dxf-classes

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

dwg-to-dxf now writes the CLASSES section, which it left out, from the drawing's class table (AcDb:Classes), and probe_dxf_classes (wired into the Corpus job) pairs every class with AutoCAD's own export of the same drawing. Follow-on to #347, #357 and #359 (#126), one PR per section; it is independent of the ENTITIES PR and touches dxf_convert.rs at one call between HEADER and TABLES.

A CLASS record is the DXF name (1), the C++ name (2), the application (3), the proxy capability flags (90), from R2004 the instance count (91), the was-a-proxy flag (280) and the entity flag (281, item class id 0x1F2), in the order of the table. For a target of R2000 or later; R12 has no CLASSES section and an R14 target is not measured.

Spec reference

ODA v5.4.1 §21 (the class section): per class the class number, the proxy flags (a BS, written unsigned: 0x8401 reads as -31743 signed), the application name, C++ class name and DXF class name, the was-a-proxy flag and the item class id, and from R2004 the instance count.

  • src/dxf_classes.rs: the writer.
  • src/dxf_convert.rs: one call between HEADER and TABLES.
  • examples/probe_dxf_tables.rs: tables_only now finds the TABLES section where it is instead of assuming it is the second (a CLASSES section sits before it).

Test plan

  • cargo fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings, RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
  • Shown working on real files, no new unit tests: cargo run --release --features dxf-reader --example probe_dxf_classes -- <dwg-corpus> pairs every written class with the export's of the same DXF name (42 drawings R2000 to R2018, 10 without a twin of the release skipped), compares groups and checks the order. Exit 0, 0 disagree:
release         written  paired  groups  agree relation  disagree  export only
AC1015 (2000)       135     135     675    675        0         0            0
AC1018 (2004)       119     119     714    695       19         0            0
AC1021 (2007)       118     118     708    690       18         0            1
AC1024 (2010)       118     118     708    697       11         0            1
AC1027 (2013)       111     111     666    655       11         0            8
AC1032 (2018)        66      66     396    388        8         0            1

Three differences between AutoCAD's export and the table are measured and applied: from R2004 the export does not list LAYOUT or ACDBPLACEHOLDER (both are listed in an R2000 export); an R2000 export names AcDbDataTable's record ACDBDATATABLE, where the table and every later export say DATATABLE; and the flags are unsigned (the first run showed -31743 where AutoCAD wrote 33793). The 67 relations are all group 91, the instance count: the export counts the objects it holds, among them those AutoCAD creates when it loads the file (more DICTIONARYVARs and CELLSTYLEMAPs) or leaves out, so the DWG's own count differs by a few on those classes. The 11 export-only classes (7 CELLSTYLEMAP, 4 DATATABLE) are ones AutoCAD registers on load; they are listed and not written.

  • The other probes on this head, still exit 0: tables (1,215 records, 0 disagree, 0 extra; same totals as main) and header.
  • python3 tools/maintainer/train/arch.py check and python3 tools/ci/spec_coverage.py --check: 0 problems.
  • cargo test --release --all-features runs in CI; I did not run it locally on this head (the change adds a module and one call).
  • Not measured on the corpus: an R14 target, the R2018 LAYOUT/ACDBPLACEHOLDER rule on a drawing whose export does list them, and the instance count's exactness (a relation, not an agreement).

Existing tests and code changed

None of the existing tests 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 (v5.4.1) is the source for §21.
  • No GPL-licensed DWG implementation source (LibreDWG, etc.) was consulted or imported.

The only other inputs are the public corpus and AutoCAD's own DXF exports of its drawings. No algorithm-description comments in other projects were read.

Developer Certificate of Origin

I affirm the contribution is my own work and may be distributed under the project's Apache-2.0 license.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-27T08:55:01.179075Z 224d5fa 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c48fad5a3

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/dxf_convert.rs Resolved
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