Skip to content

Pattern hatches with a predefined pattern (ANSI31, …) render as a solid fill - #7

Merged
albertwoo merged 1 commit into
slaveOftime:mainfrom
cstaerkel:fix/predefined-pattern-hatch
Sep 22, 2026
Merged

albertwoo merged 1 commit into
slaveOftime:mainfrom
cstaerkel:fix/predefined-pattern-hatch

Conversation

@cstaerkel

Copy link
Copy Markdown

Problem

EntityRenderDispatcher.DrawHatch decides that a hatch is a solid fill with

if (hatch.IsSolid || hatch.PatternType == HatchPatternType.SolidFill)

Hatch.PatternType is DXF group 76. The DXF reference defines that group as hatch pattern type:
0 = user-defined, 1 = predefined, 2 = custom
. ACadSharp's enum names the value 1 SolidFill
(HatchPatternType.SolidFill = 1), but that is only a name: a hatch read from a DWG or DXF with a stock
pattern such as ANSI31 carries group 76 = 1 and group 70 (IsSolid) = 0. Whether a hatch is a solid fill is
group 70 alone.

The second half of the condition therefore catches every predefined-pattern hatch read from a file, which is
the most common kind, and fills it solid. The pattern path below it (ExplodePattern, MaxHatchLines) is
correct but is only reached by hatches built in code with PatternType = PatternFill, which is why the existing
tests pass.

Fix

if (hatch.IsSolid)

A solid hatch always has IsSolid set; the library's own SquareHatch(solid: true) and SyntheticSamples set
both, so nothing that is solid today stops being solid.

Test

PredefinedPatternHatchDrawsItsPatternRatherThanAFill builds the existing pattern hatch fixture with
PatternType = SolidFill and IsSolid = false, as a file reader produces it, and asserts lines are drawn and
no fill. It fails before the change (FillPath is called) and passes after.

@albertwoo
albertwoo merged commit 3731ce2 into slaveOftime:main Sep 22, 2026
1 of 4 checks passed
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.

2 participants