Skip to content

fix(dwg): write AcDbVariableDictionary for AC1032 output too - #2886

Closed
assamaral wants to merge 1 commit into
storytold:mainfrom
assamaral:fix/dwg-ac1032-variable-dictionary
Closed

assamaral wants to merge 1 commit into
storytold:mainfrom
assamaral:fix/dwg-ac1032-variable-dictionary

Conversation

@assamaral

@assamaral assamaral commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2885 (related: #1813, #1872).

add_variable_dictionary skipped AC1032 output, so a drawing with no AcDbVariableDictionary (every ezdxf DXF) became a 2018 DWG that ZWCAD 2025's AUDIT reports as an error. This drops the AC1032 early return; a dictionary the drawing already has is still kept as is.

Tests

  • an_ac1032_dwg_stays_as_it_was replaced by an_ac1032_dwg_gets_the_variable_dictionary_too: red before the fix, green after.
  • cargo test -p cadcraft-dwg -p cadcraft-io, cargo clippy ... --all-targets -D warnings, cargo fmt --check: clean.

ZWCAD 2025 AUDIT (batch /b), ezdxf 1.4.5 R2018 line drawing → cadcraft-cli convert → AC1032

  • before: AcDbVariableDictionary Dictionary Invalid class type of (0) Invalid Removed, 1 error
  • after: 0 errors (106 objects)

Not tested: Vectric Aspire with the AC1032 DWG now carrying the dictionary (AutoCAD's own 2018 DWGs carry it, so no change is expected).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • DWG exports now include the variable dictionary across supported drawing versions, improving compatibility with applications that rely on it.
    • Existing dictionary entries are preserved. Drawings exported as AC1032 now retain the expected annotation scale and can be read with their rectangle intact.

…ld#2885)

ZWCAD 2025 AUDIT flags an AC1032 DWG without the drawing variables
dictionary ("AcDbVariableDictionary Dictionary Invalid class type of (0)").
Drop the AC1032 early return in add_variable_dictionary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

DWG export now creates AcDbVariableDictionary for every DWG version. The AC1032 test verifies the dictionary, its CANNOSCALE value, and the rectangle after readback.

Changes: Variable dictionary export

Layer / File(s) Summary
Create and verify the variable dictionary
crates/dwg/src/lib.rs, crates/io/tests/dwg_required_dictionaries.rs
add_variable_dictionary no longer skips AC1032 and newer versions. The AC1032 test checks that the dictionary exists, that CANNOSCALE is 1:1, and that CADCraft reads back the rectangle.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: nicholasgower

Merge Risk: Minimal · up to 37efe

AC1032 export adds the missing dictionary for the tested case. No concrete merge-blocking regression is established.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: writing AcDbVariableDictionary for AC1032 output.
Linked Issues check Passed [#2885] add_variable_dictionary now adds the missing dictionary for AC1032 and preserves existing entries. The updated test checks the dictionary, CANNOSCALE, and drawing readback. The PR reports …
Out of Scope Changes check Passed [#2885] The code change, updated regression test, and corrected test comment support the dictionary export fix. No unrelated changes are identified.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

[#2885] add_variable_dictionary now adds the missing dictionary for AC1032 and preserves existing entries. The updated test checks the dictionary, CANNOSCALE, and drawing readback. The PR reports zero ZWCAD AUDIT errors for the reproduction.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Finishing Touches

Generate unit tests (beta)

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

Warning

Some tools did not complete. Review the errors below.

Clippy (1.99.1)

Clippy execution timed out

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 865fa9a and 37efe6a.

Files selected for processing: 2

  • crates/dwg/src/lib.rs
  • crates/io/tests/dwg_required_dictionaries.rs

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

@austin62jake austin62jake left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested merged onto current main (865fa9a), together with #2882, #2884 and #2887, on Windows 10 Pro x64 (stable Rust). cargo xtask ci: all 7 steps pass (fmt, clippy, 3666 tests, i18n, assets, layers, wasm), including an_ac1032_dwg_gets_the_variable_dictionary_too. It merges cleanly with #2884, which edits the same file.

The change is the smallest one that does it: the early return goes, and add_variable_dictionary already keeps a dictionary the drawing has. The test now checks that the dictionary is there and that CADCraft reads its own 2018 DWG back with the rectangle. I couldn't run ZWCAD's AUDIT, so that part is your result.

@tanish2k09

Copy link
Copy Markdown
Member

A note so this doesn't surprise you after your next merge of main: main now pins craft-libs at 453b0da782 (#3338, from #3228). With it, a DWG is converted by a worker process unless the process opts in, and CI runs every test in its own process. A test here that writes or reads DWG needs this line at its start, or it fails with "no worker is configured":

cadcraft_io::dwg_worker::allow_in_process();

On Windows and macOS with plain cargo test such a test can still pass by luck, because another test in the same binary may have opted in first. Nothing else changes for this PR.

@FredApps

FredApps commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Thank you for this, @assamaral. The DWG bridge has since moved out of CADCraft: #3143 put crates/dwg into storytold/craft-libs as craft-dwg (crates/dwg there), so this change no longer has a home here. Could you re-open it against storytold/craft-libs? CADCraft picks it up with the next craft-libs pin. If part of it needs a change inside acadrust itself, that part goes to our fork, storytold/acadrust, from where it can also go upstream.

@FredApps

FredApps commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Thank you, @assamaral! The DWG bridge moved to storytold/craft-libs as craft-dwg (#3143), so I've ported this fix there as storytold/craft-libs#4971, with you credited as co-author and a bridge-level test added. Your change to dwg_required_dictionaries.rs (the AC1032 test turned round) is noted there for the rev move that brings it into CADCraft. Closing this copy here, thanks!

@FredApps FredApps closed this Dec 3, 2026
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

4 participants