Skip to content

Error in matplotlib img export of nested polylines in 1.1.X #939

Closed
@dunaden001

Description

@dunaden001

Describe the bug
This example from the documentation used to act as expected in v1.0.3 but in v1.1.0 and v1.1.1 the internal polygons (islands) are not rendered as cutouts when using ezdxf.addons.drawing.matplotlib.qsave. For clarity: it appears as if the modelspace can be exported as a DXF with the hatch correctly depicting the cutout islands in a shape - the maybe has only comes from the image export. I haven't been able to isolate what changes might be causing the issue.

To Reproduce
A small snippet that can display the issue (taken from the example linked above):

import ezdxf
from ezdxf.addons.drawing import matplotlib

# hatch requires the DXF R2000 or later
doc = ezdxf.new("R2000")
msp = doc.modelspace()

hatch = msp.add_hatch(
    color=1,
    dxfattribs={
        "hatch_style": ezdxf.const.HATCH_STYLE_NESTED,
        # 0 = nested: ezdxf.const.HATCH_STYLE_NESTED
        # 1 = outer: ezdxf.const.HATCH_STYLE_OUTERMOST
        # 2 = ignore: ezdxf.const.HATCH_STYLE_IGNORE
    },
)

# The first path has to set flag: 1 = external
# flag const.BOUNDARY_PATH_POLYLINE is added (OR) automatically
hatch.paths.add_polyline_path(
    [(0, 0), (10, 0), (10, 10), (0, 10)],
    is_closed=True,
    flags=ezdxf.const.BOUNDARY_PATH_EXTERNAL,
)

# The second path has to set flag: 16 = outermost
hatch.paths.add_polyline_path(
    [(1, 1), (9, 1), (9, 9), (1, 9)],
    is_closed=True,
    flags=ezdxf.const.BOUNDARY_PATH_OUTERMOST,
)

matplotlib.qsave(msp, "nested_polylines.png")

Expected behavior
Expected behavior is to have the inner polyline removed from the outer polyline as shown:
1_0_3_tutorial_export

Actual behavior is to only display the outer polyline (or perhaps to also render the inner polyline but also filled).
1_1_1_tutorial_export

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions