Repository navigation
feat(dxf): write the decoded header into dwg-to-dxf's HEADER section (#126) - #320
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3dd56b298c
ℹ️ 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".
…126) src/dxf_header.rs turns the decoded AcDb:Header into the $VARIABLE groups AutoCAD's own export writes for the same drawing, and nothing else: a variable the export omits ($PELLIPSE, $FACETRES, the unknown slots, control-object handles) is omitted, and so is one the DWG cannot give (local $TDCREATE and $TDUPDATE, $ACADMAINTVER, a true colour, a null default visual style). Group codes and the first release of each variable are measured on the 50 AutoCAD exports of the corpus. Handles that DXF writes as names are resolved through the decoded symbol-table records (an undecodable record still gives its name as the first string of its string stream); $CMLSTYLE takes the dictionary key's case and a standard arrowhead block loses its underscore. $MEASUREMENT is read from AcDb:Template (§22), $DWGCODEPAGE from the file header and $LASTSAVEDBY from AcDb:SummaryInfo. R12 and R14 targets keep $ACADVER alone: no AutoCAD export of either exists to measure against. examples/probe_dxf_header.rs converts every drawing that has an AutoCAD export, reads dwg-to-dxf's output back with dxf_reader and compares every variable: 9,514 agree, 173 hold a stated relation (a later save), 0 disagree, 0 extra, and each of the 147 omissions has a stated reason. The Corpus job runs it. tests/integration_dxf_roundtrip.rs told group-code lines from value lines by their shape, which a header value such as $TREEDEPTH's 3020 defeats; it now reads the file as the code and value pairs it is.
…s angles, text and arrowheads as DXF reads them (#126) The converter writes layer 0 and no other symbol table, so a header naming any other layer, style, linetype, dimension style, mline style, UCS or block would point at nothing: those names are omitted (an empty name is kept), and the probe lists each as an omission with that reason. $ANGBASE is radians in the database and degrees in DXF group 50, so groups 50 to 58 are converted. Before R2007, whose DXF reads bytes in $DWGCODEPAGE, non-ASCII header text is written as \U+XXXX escapes. The leading underscore is dropped only from AutoCAD's standard arrowhead block names; any other block keeps its name.
309c729 to
9d23373
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d23373272
ℹ️ 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".
… every value on one line (#126) $CMATERIAL, $INTERFEREOBJVS and $INTERFEREVPVS name MATERIAL and VISUALSTYLE objects, which the converter exports as untyped placeholders; the references are omitted until it exports them as their types ($HANDSEED, the next free handle, is still written). A control character in a header string, a line feed above all, would have put the rest of the value on the next group-code line; it is now written in DXF's caret notation, with the caret itself as a caret and a space.
…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.
…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.
Summary
dwg-to-dxfnow writes the decodedAcDb:Headerinto the DXFHEADERsection under the names and group codes AutoCAD's own export uses, and a probe reads its output back and compares every$VARIABLEwith that export. Follow-on to #302 (#126).A variable AutoCAD's export omits is omitted here too; nothing is written with a default. R12 and R14 targets keep
$ACADVERalone: no AutoCAD export of either is in the corpus to measure the set against.Spec reference
ODA v5.4.1 §9 (the variables), §22 (
$MEASUREMENT), §3.2.5 and §4.1 (code page). The group codes and the first release of each variable are measured on the 50 AutoCAD DXF exports (AC1015 to AC1032) of the public corpus, which agree with each other;ARCHITECTURE.md§7r (the section #302 landed as7n, renumbered here because three sections now carry7n) has the table and the rules.src/dxf_header.rs: the table ($NAME, group codes, first release) and the conversion. Handles DXF writes as names go through the decoded symbol-table records (an undecodable record still gives its name as the first string of its string stream);$CMLSTYLEtakes itsACAD_MLINESTYLEdictionary key's case; a standard arrowhead block loses its underscore; a colour is its AutoCAD index (a true colour has none and is omitted); a null handle variable is omitted;$ANGBASEis converted from radians to degrees (DXF group 50); before R2007 non-ASCII text is written as\U+XXXXescapes; the underscore is dropped only from AutoCAD's standard arrowhead names; before R2010$XCLIPFRAMEis the flag 290 and 2 is written false.$MEASUREMENTis read fromAcDb:Template,$DWGCODEPAGEfrom the file header (29 and 30 measured) and$LASTSAVEDBYfromAcDb:SummaryInfo.src/dxf_sections.rs:HeaderValue::Groups/HeaderGroupfor explicit group codes; reals are written shortest round-trip with DXF's exponent form.examples/probe_dxf_header.rs(dxf-readerfeature), wired into the Corpus job.AcDb:Templatedescription length counts UTF-16 units (AutoCAD writes 1 and two bytes), where §22 counts bytes.Test plan
cargo fmt --all -- --check,cargo clippy --all-targets --all-features -- -D warningscargo run --release --features dxf-reader --example probe_dxf_header -- <dwg-corpus>over the 42 drawings that have an AutoCAD export (AC1014 and the two drawings without a twin are skipped and listed):Relation is the later-save rule for
$TDUUPDATE,$TDINDWG,$TDUSRTIMER,$HANDSEEDand$VERSIONGUID(the twin is saved after the DWG). Extra is a variable written that the export omits: none. Each of the 375 omissions has a stated reason the probe checks: local$TDCREATEand$TDUPDATE(the DWG holds universal time),$ACADMAINTVER(not derivable from the file header), a true-colour$CECOLOR, a null$INTERFEREOBJVSor$INTERFEREVPVSwhere AutoCAD names a default visual style, and a name for a symbol record the output does not define (the converter writes layer 0 and no other symbol table, so$TEXTSTYLE,$DIMSTYLE,$CELTYPE,$CMLSTYLE, a non-zero$CLAYERand the like are omitted until those tables are written, rather than left pointing at nothing). One without a reason fails the probe.dwg-to-dxf line_2013.dwg out.dxf --version R2013writes 248$variables.probe_header_vars(from feat(sections): decode every AcDb:Header variable from one table (§9, #126) #302) unchanged: 52 of 52 close, 11,544 agree, 316 relation, 0 disagree.cargo test --all-features --test integration_dxf_roundtrippasses; the fullcargo test --release --all-features(929 tests) passed on the branch before the rebase and before the Codex fixes. The$ANGBASEconversion (the corpus value is zero) and the\U+XXXXescape (all corpus header text is ASCII) are not measured on the corpus.Existing tests and code changed
tests/integration_dxf_roundtrip.rs::output_is_valid_utf8_with_line_based_pairstold group-code lines from value lines by their shape (a short all-digit line is a code);$TREEDEPTH's value3020is such a line. It now reads the file as the code and value pairs it is. Assertion kept: every code is an integer in 0..=1071, and there are at least ten.src/bin/dwg_to_dxf.rspanicked at startup in debug builds (clap: the custom--version <R2018>argument clashes with clap's own version flag).disable_version_flag = true.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:
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.