Repository navigation
feat(dxf): write the BLOCKS section, paired with AutoCAD's export (#126) - #371
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: 33bcaad69c
ℹ️ 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".
…up the block records once (#126)
# Conflicts: # .github/workflows/ci.yml # src/lib.rs
# Conflicts: # ARCHITECTURE.md
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 273c820aaf
ℹ️ 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".
…index each table's order once (#126)
# Conflicts: # ARCHITECTURE.md
…10-27 (#416) * docs: bring README, ROADMAP and CHANGELOG up to the landings of 2026-10-27 README's code-page and DXF writer text named work in review that has landed (#371, #380, #382, #384); jev_review.py prose ranked those sentences 0.72 to 0.96. ROADMAP's "where it stands" table was a 2026-10-21 snapshot whose numbers, CI row and release row were all out of date; it now points to the rendered numbers instead of repeating them. CHANGELOG gains #371, #380, #382, #384, #385 and #404. * docs(changelog): record the CI-only merge train (#408) * docs: OBJECTS landed (#372): README, ROADMAP and CHANGELOG * docs: LAYOUT, GROUP and MLINESTYLE (#373), the class map writer (#405) and the double-byte round trip (#414) landed * docs: VISUALSTYLE landed (#413) * docs(readme): name the skipped types still in review without per-type counts; MATERIAL landed (#325) * docs(readme): point to the open decoder PRs instead of a list that each landing makes stale
Summary
dwg-to-dxfnow writes the BLOCKS section: one block perBLOCK_RECORD, in the table's order, each with itsBLOCK, the entities the ENTITIES writer collects for it and itsENDBLK, andprobe_dxf_entities --section=BLOCKS(wired into the Corpus job) pairs every record with AutoCAD's own export. Follow-on to #358 (#126), one PR per section. It lifts the gate #358 put on INSERT, so the INSERTs, ATTRIBs and ATTDEFs that wait for a written block definition are written now. An INSERT is written only when the block it names is:block_markersdecides the blocks written before any entity is accepted, and an INSERT of a block that cannot be written (its layer or linetype is not in the tables, a base point that is not finite) is countedINSERT (its block is not written)with its ATTRIBs, so no output names a block it lacks. The BLOCKS write groups the entity records by block once instead of rescanning them for every block.The tables are built a second time knowing which entities and blocks are written, so the header's
$DIMBLKfamily, a DIMSTYLE's arrowhead blocks and a BLOCK_RECORD's{BLKREFSname only what is in the output (theBLOCKS_EXPORTEDconstant #347 added for that is gone).Spec reference
ODA v5.4.1 §20.4.6 BLOCK and §20.4.7 ENDBLK, §20.4.5 ATTDEF, §20.4.52 BLOCK HEADER for the record each block hangs from, and the entity sections of #358 for the contents.
src/dxf_blocks.rs: the writer;src/dxf_entities.rs:block_markers(the BLOCK and ENDBLK of each record, withAcDbBlockBeginandAcDbBlockEnd), ATTDEF, the children order, the INSERT gate lifted.src/dxf_blocks.rs: the records grouped by owning block once (O(blocks + entities));src/dxf_entities.rs: the INSERT gate on the set of blocks written.src/dxf_convert.rs: tables built twice;src/dxf_tables.rs:definedtakes the written blocks;src/dxf_header.rs:$DIMBLKresolves through them.Test plan
cargo fmt --all -- --check,cargo clippy --all-targets --all-features -- -D warnings,RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-featurescargo test --release --all-features: 921 passed, 0 failed across 26 result lines, run onc982644, the head of this branch; this branch adds no unit test.cargo run --release --features dxf-reader --example probe_dxf_entities -- --section=BLOCKS <dwg-corpus>pairs every record of the section with the export's of the same handle (42 drawings R2000 to R2018, 10 without a twin of the release skipped): 1,532 written, 1,503 paired, 12,583 groups, 12,577 agree, 0 disagree, 0 extra, in AutoCAD's order. Exit 0.The 29 records that do not pair are the BLOCK, ENDBLK and entities of one block per drawing that the export registers again under new handles (
*U25of the ACadSharp saves; the tables probe pairs the record by name), counted with their reason. The six groups that do not agree are a relation the probe names: a dynamic block of R2000 to R2007 ismy-dynamic-blockin the DWG and*U17in the export. Not written yet, counted by kind: 24 VIEWPORTs, one multi-line ATTDEF (R2018) and 38 MTEXTs with a background fill or an embedded object. The ENTITIES probe with the INSERTs and ATTRIBs back: 803 entities, 5,627 groups, 0 disagree; tables: 1,239 records, 0 disagree, 0 extra.--section=BLOCKSconverts every drawing to every release the writer writes it to and checks each INSERT's group 2 against the BLOCKs of the same output (510 INSERTs in 264 conversions, 0 unresolved), and, since no corpus drawing has a block the writer must leave out, builds each drawing's entities once per layer with that layer out of the tables (160 builds, 283 blocks left out, 85 INSERTs countedINSERT (its block is not written), 0 of the 1,580 written unresolved). With the gate temporarily disabled the second run exits 1 (18 of 1,598 INSERTs name a block not written). Negative run of the first check,PROBE_DXF_ENTITIES_DROP_BLOCK=1: 72 unresolved, exit 1. Either check that measures nothing printsNOT MEASURED:at line start, which the Corpus step fails on.positionsearch per key (synthetic 50,000 records: 120.8 s before, 11 ms after, measured on the sort-key expression in isolation).python3 tools/maintainer/train/arch.py checkandpython3 tools/ci/spec_coverage.py --check: 0 problems.Existing tests and code changed
None of the existing tests changed.
dxf_tables::BLOCKS_EXPORTEDis removed anddefinedtakes the written blocks.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.