Skip to content

craft-dwg: write AcDbVariableDictionary for AC1032 output too - #4971

Open
FredApps wants to merge 1 commit into
mainfrom
port/cadcraft-2886
Open

FredApps wants to merge 1 commit into
mainfrom
port/cadcraft-2886

Conversation

@FredApps

@FredApps FredApps commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Port of storytold/cadcraft#2886 by @assamaral. The DWG bridge moved here as craft-dwg in storytold/cadcraft#3143, so the crates/dwg part of that PR is re-opened here, with the author credited as co-author of the commit.

Fixes storytold/cadcraft#2885 once CADCraft moves its craft-libs rev.

What. The drawing variables dictionary (AcDbVariableDictionary) is added to 2018 (AC1032) DWGs too, not only older ones. ZWCAD 2025's AUDIT reports an AC1032 DWG without it as an error (storytold/cadcraft#2885).

Tests (crates/dwg): an_ac1032_dwg_gets_the_variable_dictionary (new here; the CADCraft PR tested it through cadcraft-io).

CADCraft side. CADCraft's crates/io/tests/dwg_required_dictionaries.rs has an_ac1032_dwg_stays_as_it_was, which expects no dictionary in a 2018 DWG. The rev move that brings this in needs that test turned round as the original PR did (an_ac1032_dwg_gets_the_variable_dictionary_too).

Verification (Linux x86-64, on craft-libs main 092a2c6): rustfmt on the file, cargo clippy -p craft-dwg --all-targets -- -D warnings, cargo test -p craft-dwg all pass. Not run: Windows, macOS, wasm32, FreeBSD, and the CADCraft side, which needs the rev move. The craft-libs runners are stalled, so CI hasn't run yet.

Summary by CodeRabbit

  • Bug Fixes
    • AC1032 drawings now include the variables dictionary when it is missing.

Ported from storytold/cadcraft#2886 by @assamaral, onto the DWG bridge that moved here in storytold/cadcraft#3143.

Co-authored-by: assamaral <217119886+assamaral@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes

The DWG export path no longer skips adding AcDbVariableDictionary for AC1032 drawings. A test converts a minimal DXF to AC1032 DWG and checks the dictionary after reading the DWG back.

AC1032 variable dictionary

Layer / File(s) Summary
Add and verify the variable dictionary
crates/dwg/src/lib.rs
The AC1032 early return was removed. When the named-objects root is a dictionary and lacks AcDbVariableDictionary, the export path can add it. The test checks that the dictionary is present after conversion and read-back.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: dylanmtaylor, sbaksa

Merge Risk: Minimal · up to 2baee

AC1032 DWG exports now include the variable dictionary, as other versions already did, which should fix the audit error reported in the linked issue. No merge-blocking risk was found in this crate.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: AcDbVariableDictionary is now written for AC1032 (2018) DWG output, matching the raw summary (add_variable_dictionary no longer skips AC1032) and the PR objectives. It…
Linked Issues check Passed [#2885] Requirement: a DWG written as AC1032 (2018) must contain AcDbVariableDictionary, so ZWCAD 2025 AUDIT reports zero errors. The keep-existing-dictionary rule must stay. The reviewed head's crate…
Out of Scope Changes check Passed The changes in crates/dwg/src/lib.rs are limited to add_variable_dictionary (AC1032 case removed, comments updated) and one test for the AC1032 dictionary. Both connect directly to #2885. The PR descr…
Full details: Title check

Explanation

The title names the main change: AcDbVariableDictionary is now written for AC1032 (2018) DWG output, matching the raw summary (add_variable_dictionary no longer skips AC1032) and the PR objectives. It also names the affected crate, craft-dwg. The title is short, specific, and does not describe anything absent from the changeset.

Full details: Linked Issues check

Explanation

[#2885] Requirement: a DWG written as AC1032 (2018) must contain AcDbVariableDictionary, so ZWCAD 2025 AUDIT reports zero errors. The keep-existing-dictionary rule must stay. The reviewed head's crates/dwg/src/lib.rs (whole-PR diff summary) shows that add_variable_dictionary no longer returns early for AC1032. When the named-objects root is a dictionary without AcDbVariableDictionary, it adds the dictionary for every version. The summary also states that the existing rule to keep an existing dictionary is unchanged. A test, an_ac1032_dwg_gets_the_variable_dictionary, checks AC1032 output for the dictionary. The file read was truncated at 16000 bytes, so I could not read the add_variable_dictionary body or the new test directly. The PASS rests on the diff summary and the PR description. Coding requirements are met by the crate change. The CADCraft test change named in the PR description is outside this repository and is not a requirement of this PR's crate-level scope.

Full details: Out of Scope Changes check

Explanation

The changes in crates/dwg/src/lib.rs are limited to add_variable_dictionary (AC1032 case removed, comments updated) and one test for the AC1032 dictionary. Both connect directly to #2885. The PR description and the diff summary report no unrelated edits. The CADCraft-side test rename is described as a follow-up that depends on a craft-libs rev move; it is not part of this repository diff. Verification was run on Linux only, which affects CI confidence but not scope.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 092a2c6 and 2baee54.

Files selected for processing: 1

  • crates/dwg/src/lib.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@sonarqubecloud

sonarqubecloud Bot commented Dec 3, 2026

Copy link
Copy Markdown

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.

DWG export (AC1032): a drawing without an AcDbVariableDictionary gives a DWG that ZWCAD 2025 AUDIT reports as an error, e.g. every DXF made by ezdxf

1 participant