Skip to content

feat(dxf): write the LAYOUT, GROUP and MLINESTYLE objects, paired with AutoCAD's export (#126) - #373

Merged
DrunkOnJava merged 54 commits into
mainfrom
feat/dxf-layouts
Oct 27, 2026
Merged

DrunkOnJava merged 54 commits into
mainfrom
feat/dxf-layouts

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Stacked on #372 (OBJECTS) and #371 (BLOCKS): this branch contains their commits, so until they land the diff shows all three; this change is the last commit, 662b6a5.

dxf_objects writes three more kinds of the OBJECTS section: LAYOUT (its plot settings, then the layout proper and its handles), GROUP (description, flags and one 340 per member) and MLINESTYLE (name, flags, description, fill colour, angles and the per-line offset, colour and linetype), each from the decoder that already closed on the corpus, with probe_dxf_objects pairing each with AutoCAD's own export. Follow-on to #372 (#126). With the layouts written, a BLOCK_RECORD's 340 and the ACAD_LAYOUT dictionary's entries are written too.

Spec reference

ODA v5.4.1 §20.4.84 LAYOUT (the plot settings it opens with, then its own fields, then the handles: from R2004 the plot view, from R2007 the visual style, the paperspace block record, the last active viewport, the base and named UCS), §20.4.72 GROUP, §20.4.73 MLINESTYLE.

  • src/dxf_objects.rs: layout_groups, mline_style_groups, the GROUP arm, and kinds (an MLINESTYLE of R2018 names its linetypes by handle, which is not resolved yet, so it is not written for that target).

Test plan

  • cargo fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings, RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
  • cargo test --release --all-features: 921 passed, 0 failed on feat(dxf): write the OBJECTS section, paired with AutoCAD's export (#126) #372's head; the full run on this head is in progress and CI runs it (this PR adds no unit test).
  • Shown working on real files, no new unit tests: cargo run --release --features dxf-reader --example probe_dxf_objects -- <dwg-corpus> (42 drawings R2000 to R2018): exit 0, 0 disagree, 0 extra, in AutoCAD's order.
kind                    written  paired  groups   agree relation  disagree  extra  om.grp
GROUP                        12      12     144     144        0         0      0       0
LAYOUT                      132     132    8182    8182        0         0      0     126
MLINESTYLE                   40      40     640     640        0         0      0       0

The 126 groups a LAYOUT omits are extended data (the ACAD_PSEXT application data, 1000 to 1070, 108), not decoded, and 18 last active viewport handles (331) that name a VIEWPORT, which is not written yet: layout_groups writes 331, 345 and 346 only when the output defines the record, and the probe counts each omission with that reason. The probe also compares every 330 after the owner now, so a LAYOUT's block record is checked. The two MLINESTYLEs not written are the R2018 records. Five LAYOUTs carry an extension-dictionary bracket the export lacks; each names a dictionary the export leaves out (the same rule that applies to the tables), and the probe checks that before it accepts the omission. The export's group order puts 70 after 143 in the plot settings and the shade plot triple after 147; both are followed. The other probes on this head still exit 0: tables (1,239 records, 8,893 groups, 0 disagree, 0 extra; the 340 of BLOCK_RECORD is written now), entities, BLOCKS, header, header variables, entity colour.

  • python3 tools/maintainer/train/arch.py check and python3 tools/ci/spec_coverage.py --check: 0 problems.
  • Not corpus-measured: a non-null base or named UCS (345, 346), a plot view handle on R2004 and later (its name is 6), a visual style handle (333), an MLINESTYLE whose linetype is neither sentinel (32767, 32766), and R2018 MLINESTYLE.

Existing tests and code changed

None.

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 §20.4.72, §20.4.73 and §20.4.84.
  • 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-27T22:53:25.890929Z 9d70ee0 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: 662b6a5fbf

ℹ️ 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_objects.rs Resolved
Comment thread src/dxf_objects.rs Resolved
Comment thread src/objects/xrecord.rs Resolved
# Conflicts:
#	.github/workflows/ci.yml
#	src/lib.rs
…ECORD string in a code page not decoded, compare the 330 groups of objects (#126)
…output defines them, and take the kinds by the drawing's release (#126)
# Conflicts:
#	.github/workflows/ci.yml
#	ARCHITECTURE.md
#	src/dxf_convert.rs

@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: eea320af1e

ℹ️ 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_objects.rs Resolved
Comment thread src/dxf_objects.rs Resolved
Main's OBJECTS section text (7aw) and code stand word for word; the LAYOUT, GROUP and
MLINESTYLE section is renumbered 7ax and the three files it changes sit on main's
version of the OBJECTS writer and probe.

@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: d00a65bae3

ℹ️ 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_objects.rs Resolved
… that a layout name leaves ASCII (§3.2.5, #375, #126)

The bytes-API check required convert_dwg_to_dxf_bytes to write exactly the bytes
convert_dwg_to_dxf writes, which held only while no text of the corpus left ASCII. The
ACAD_LAYOUT dictionary of the GBK drawings now writes its layout name as a key: the String
writer spells it as the escape of each character, the page writer as the page's bytes
(B2 BC BE D6 31), which are the bytes AutoCAD's own export holds. The check is now that the
bytes read back under the drawing's page to the String writer's text once every character
above ASCII is spelled as its escape again, and that at least one conversion writes page
bytes, so it still fails if the page writer stops encoding.
…ts and plot settings already are (§20.4.84, #126)

layout_groups checked the plot settings, the limits and the elevation for a NaN or an
infinity but not the insertion point, the extents and the UCS origin and axes, which
BitCursor::read_bd also returns as read; the record was written with NaN or inf, which the
DXF reader rejects. The check is now layout_is_finite over all of them, and a synthetic
check in probe_dxf_objects refuses all 63 cases (a NaN, an infinity and a negative infinity
in each of the 18 coordinates of the six points and in one real of each other kind).
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 27, 2026 22:56
@DrunkOnJava
DrunkOnJava merged commit 57b1312 into main Oct 27, 2026
25 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/dxf-layouts branch October 27, 2026 23:07
DrunkOnJava added a commit that referenced this pull request Oct 27, 2026
DrunkOnJava added a commit that referenced this pull request Oct 27, 2026
#373 landed, so main holds the LAYOUT, GROUP and MLINESTYLE section as 7az and the OBJECTS
and LAYOUT code with its later fixes; the VISUALSTYLE section follows as 7ba and the three
files it changes sit on main's version of them.
DrunkOnJava added a commit that referenced this pull request Oct 28, 2026
…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
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