Repository navigation
fix(dxf): preserve LEADER vertex Z coordinates (#2245) - #2397
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Scope coordinates to each LEADER vertex crates/io/src/dxf_read/entities.rs |
Each group 10 coordinate now uses group 20 and 30 values from the same vertex segment. Missing Y or Z values default to zero. |
Verify LEADER vertex elevations crates/io/tests/it/leader_vertex_elevation.rs, crates/io/tests/it/main.rs |
Integration tests check vertex order and coordinates, LEADER and common properties, and entity metadata across DXF and DWG round trips. They also test eight patterns of present or missing Z values in authored DXF tags. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: aiongg
Merge Risk: 
Minimal · up to d13d0
-
LEADER elevations are parsed per vertex. No merge-blocking risk was identified; normal CI checks should run before merge.
Pre-merge checks: 
3 · 
2
-
Failed checks: 2 warnings Passed checks: 3 passed-
Full details: Out of Scope Changes check
-
Explanation
The production change is limited to the LEADER arm in
crates/io/src/dxf_read/entities.rs. The new integration tests directly verify#2245behavior and related LEADER and Common properties. No unrelated entity reader, writer, codec, dependency, format marker, or external asset changes are present.
-
Full details: Linked Issues check
-
Explanation
#2245requires preservation of each LEADER XYZ vertex without normalization or tolerance. The parser change scopes group 20 and group 30 values to each group 10 vertex and defaults a missing Z to zero. The added default-enabled tests cover XYZ values, missing-Z patterns, properties, repeated saves, DXF ASCII/binary, and native-target DWG acrossVersion::ALL. However, the PR states that the regression tests were not executed locally. The corresponding#2237regression tests remain absent and ignored, and the required listed checks, neighboring families, and applicable matrix have not been run or shown as passing.Resolution
Add or enable the corresponding
#2237regressions when they are available in this test tree. Run both listed DXF and DWG regression commands, the neighboring families, and the applicable save-version and encoding matrix. Record passing results.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. 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 5 functions across 3 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
assamaral
left a comment
There was a problem hiding this comment.
Tested with a local build of this PR (d13d087) and ZWCAD 2025, DXF and DWG sides. All data synthetic (ezdxf, DXF 2018).
Fixture: four LEADERs in model space: vertices (0,0,4) (5,5,7) (10,5,7); a planar control; one with negative/mixed Z (-3.5, 0, 12.25); one with four vertices (Z 1,2,3,4).
cadcraft-cli convertto DXF and DWG with this build, then both files opened in ZWCAD 2025 and re-exported with_DXFOUT2018: groups 10/20/30 of every vertex are identical to the control (the source DXF opened and re-exported by ZWCAD the same way), for all four leaders, from both the DXF and the DWG route. The same conversion with main (5654240) gives Z = 0 for every vertex of every leader, through DXF and DWG, as the issue says.- Sparse Z: a 4-vertex LEADER with group 30 removed from vertices 1 and 3 (raw edit). This build writes Z = 0, 2, 0, 4, and so does ZWCAD's own reading of the source (control): the omitted Z does not shift the next vertex's Z onto the previous one. Both ZWCAD re-exports (from the DXF and the DWG written by this build) match the control.
- Regression: a real production drawing (private, ~10 MB DXF, 1.7k TEXT, no LEADER in it) converted to DXF and DWG with this build and with main: the files are byte-identical (same MD5 for DXF and for DWG). So the only change is the LEADER arm, as the description says.
- Reading the diff:
tags.split(|t| t.code == 10).skip(1)gives each vertex the slice up to the next group 10, which for the last vertex also covers the trailing LEADER groups (71/72/76/340/77/210…). That is fine because no other LEADER group uses 20 or 30, so the last vertex cannot pick up a foreign Y/Z; worth a one-line comment if you touch it again. cargo test -p cadcraft-io --test it leader_vertex_elevationon this head: 3 passed. Not exercised: how ZWCAD draws the leaders (I compared exported groups only).
Verdict: APPROVE.
|
Independently verified on Linux x86_64 (Arch, current Rust stable) against The tests prove the bug. Plain That is #2245 exactly: every vertex flattened, not just a mis-ordered list. On the branch (merged with main): The mixed set (one LEADER at Z 4/7/-3, one wholly planar at Z 0) is what makes this a real test rather than a coincidence — a fix that copied Z from a neighbour would fail the planar control, and Useful context for the reviewer: #2238 A7 currently has no default-enabled coverage on Confidence: 99% (negative control and branch run both clean, full io suite unchanged otherwise). |
austin62jake
left a comment
There was a problem hiding this comment.
Tested on Windows 10 Pro x64 (Rust 1.99.1, cargo-nextest 0.9.150), with this PR merged onto current main (336243e). It merges cleanly, and it works.
The description says the tests weren't run locally, so I ran them:
- All 3
leader_vertex_elevationtests pass with the fix and all 3 fail onmain: DXF (ASCII and binary) and DWG, every version inVersion::ALL, two saves each, and all eight Z-presence patterns. cargo xtask cipasses all 7 steps (2622 tests) with this PR merged ontomaintogether with five other small, unrelated PRs I tested at the same time (#2406, #2408, #2417, #2418, #2404, #2397), and #2198 so the gate runs on Windows.
The slice for the last vertex runs to the end of the record, but no LEADER group after the vertices uses code 20 or 30 (the normal and direction vectors are 210-233), so it can't pick up a stray Y or Z.
Problem
Saving and reopening a LEADER flattens its vertex elevations to zero through both DXF and the DWG bridge (#2238 A7).
Root cause
The LEADER DXF reader uses the two-dimensional
T::pts(10)helper and then callsto3(0.0), discarding group 30. The writer already emits group 10/20/30 for each vertex. Autodesk's LEADER DXF reference identifies those as the vertex's X/Y/Z coordinates.Changes
dxf_read/entities.rs.Tlookup helpers.Regression coverage
Added three default-enabled, synthetic tests (authored, not executed locally):
(1, 2, 4),(5, 6, 7),(9, 10, -3), plus wholly planar controls.DXF/DWG compatibility
The reader handles the interleaved vertex groups written by CADCraft and the existing DWG bridge. An absent Z remains zero without consuming a subsequent vertex's Z. Ordinary 2D LEADERs keep their coordinates. No DWG codec, third-party source, dependency, format marker or external asset is changed.
This addresses the shared DXF-path loss; it does not claim two independent codec fixes or independent DWG interoperability. No SPLINE, MLINE, MULTILEADER, DIMENSION, extrusion or unrelated preservation changes are included.
Verification
Passed locally:
git diff --check, staged diff whitespace checks, strict UTF-8 inspection and full diff review. Checked test registration, the public IO/type signatures, per-vertex scoping, unchanged writers/Common parsing, and absence of new unwrap/expect/panic/unsafe or ignored tests.No local Rust/Cargo compilation, tests, rustfmt, Clippy, xtask, WASM builds or dependency downloads were performed. Regression tests were added but not executed locally; runtime behavior and formatting remain subject to GitHub CI. No first-save normalization or comparison tolerance was added.
Focused check for CI/maintainers (not run locally):
cargo test -p cadcraft-io --test it leader_vertex_elevationRelated
Fixes #2245. Related: #2238 A7 and #2237.
At review time #2237 remains open at
ed37a1c8f83d7d995afacc4ace6dae32dd1f9483. Itsroundtrip::dxf::extended::leaders_3dandroundtrip::dwg::extended::leaders_3dare still ignored and absent from this branch's test tree. This PR does not cherry-pick its framework or modify that PR.When the matrix is available with this fix, review enabling those two regressions and execute them together with neighboring families across the applicable save-version/encoding domains. The Issue's full matrix acceptance has not been run or claimed complete here. Only in an environment containing those tests are these exact commands applicable:
Prepared with AI assistance for @Zaxaerith.
Summary by CodeRabbit
Bug Fixes
Tests