Repository navigation
DXF: a solid or gradient hatch no longer makes AutoCAD refuse the file - #2904
1 commit merged into
Conversation
Since storytold#2665 the writer put groups 52, 41 and 77 (pattern angle, scale, double flag) on solid fills too. AutoCAD 2024 writes none of them there and refuses a DXF whose solid HATCH has any of them: "Error: expected group code 98 / Invalid or incomplete DXF input -- drawing discarded". So every DXF CADCraft saved with a solid or gradient hatch, including an AutoCAD drawing passed through it, was discarded by AutoCAD. They are written for pattern fills only again, as before storytold#2665. Measured in AutoCAD 2024: CADCraft's file with each of the three groups dropped alone is still refused, with all three dropped it opens; with this change AutoCAD opens CADCraft's solid, gradient and pattern hatches and a 46-object drawing, DXF and DWG, with AUDIT reporting 0 errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
eliets2
left a comment
There was a problem hiding this comment.
First-pass review notes (automated; combined from specialist angles: docs and text). Please treat as suggestions and verify before acting.
Summary: This change writes DXF groups 52, 41 and 77 only for pattern hatches again, omitting them for solid and gradient hatches so the HATCH record goes from 76 directly to 98, and replaces the hatch serialization test to assert that ordering.
Logical units:
- DXF writer change in
write_hatch_entityincrates/io/src/dxf_write/entity.rsto omit 52, 41 and 77 for solid and gradient hatches - Test replacement in
crates/io/src/tests.rswithsolid_and_gradient_hatches_have_no_pattern_groups
Findings:
- [docs]
docs/file-format-parity.md, "HATCH pattern / solid" row: the row still describes the old behavior where solid hatches keep angle, scale and double flag, whilewrite_hatch_entitynow omits 52, 41 and 77 for solid and gradient hatches and drops their angle and scale on save. Update the row to state that solid and gradient hatches go from group 76 directly to 98 with no 52, 41, 77 or 78, that pattern hatches keep 52, 41, 77 and 78, and that angle and scale on a solid hatch are not preserved through a save.
Overlaps: None listed.
Verdict: Needs changes. 1) The parity row still describes the old solid-hatch behavior. 2) The row must state solid and gradient hatches go 76 directly to 98 with no 52, 41, 77 or 78, while pattern hatches keep those groups. 3) The row must state angle and scale on a solid hatch are not preserved through a save.
|
Thanks for the review. I left
|
|
Independent confirmation from the released build, in case it helps get this merged. v0.20.1 ( Minimal repro, one SOLID hatch built with ezdxf 1.4.3: import ezdxf
doc = ezdxf.new("R2018")
h = doc.modelspace().add_hatch(color=1) # solid fill
h.paths.add_polyline_path([(0, 0), (10, 0), (10, 10), (0, 10)], is_closed=True)
doc.saveas("solid_hatch_in.dxf")HATCH groups from 97 on:
On a real drawing: an AutoCAD-origin DXF (about 9 MB, roughly a thousand dynamic block references, many solid hatches) written back to DXF by v0.20.1 was refused with the same error. After removing only the 52/41/77 pairs from the solid hatches ( DWG save is unaffected here too: AutoCAD 2026 opened v0.20.1's DWG of the same drawing with AUDIT 0 errors. |
|
Thanks for checking this in AutoCAD 2026. It matches what I measured in AutoCAD 2024: the reader refuses 52, 41 or 77 between 76 and 98 on a solid fill, and the same drawing opens once they're gone.
|
97c5670
What
Since #2665, every DXF that CADCraft writes with a solid or gradient hatch is refused by AutoCAD 2024. AutoCAD discards the whole drawing, not just the hatch:
#2665 made the writer put groups 52 (pattern angle), 41 (pattern scale) and 77 (double flag) on solid fills too. It said AutoCAD keeps them there, but that wasn't checked in AutoCAD: its fixtures were synthetic files. AutoCAD 2024 writes none of the three on a solid or gradient fill. Its HATCH record goes from 76 straight to 98, and its reader refuses any of the three in that place.
This PR writes 52, 41 and 77 for pattern fills only again, as before #2665. Pattern fills are unchanged.
Measured in AutoCAD 2024
Each file was opened with accoreconsole and its objects counted, or its read error recorded. The drawings are self-built.
main(865fa9a): a rectangle, a SOLID hatch, a rectangle, an ANSI31 hatch, saved as DXFexpected group code 98main: a rectangle and a gradient hatch (LINEAR, 30°)entgetshows the ANSI31 at 52 = 0.523599 rad and 41 = 2.0, the gradient as LINEAR, and no 52 or 41 on the solid fillsmainexpected group code 98Total errors found 0Total errors found 0AutoCAD's own DXFOUT of a solid hatch writes
75 76 98with nothing between 76 and 98.DWG save isn't affected. It goes through acadrust, and AutoCAD opened CADCraft's DWG of the same drawing (4 objects).
Tests
solid_and_gradient_hatches_have_no_pattern_groupsincrates/io/src/tests.rsreplaces #2665'ssolid_hatch_keeps_angle_scale_and_double_flag, which asserted the opposite. It checks:52 = 30,41 = 2;A mutation run made four changes, and the test caught each one:
main;Not in this PR
A solid hatch read with an angle and a scale no longer keeps them through a save, which was #2665's aim. AutoCAD doesn't keep them on a solid fill either:
entgetshows no 52 or 41 there. If they're wanted, CADCraft's own xdata could carry them, but this PR doesn't do that.Parity row: "HATCH pattern / solid" in
docs/file-format-parity.md, as #2665 named it.🤖 Generated with Claude Code
Summary by CodeRabbit