Skip to content

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

Closed

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

Activity

  1. added a commit that references this issue on Oct 14, 2023
  2. dev-hack95 commented on Oct 18, 2023

    @dev-hack95

    Can i contribute in this, actually i am working on this library and want to know better and also good at matplotlib

  3. dev-hack95 commented on Oct 18, 2023

    @dev-hack95

    which is the branch btw

  4. mozman commented on Oct 18, 2023

    @mozman
    Owner

    Hi!

    @dev-hack95 Thank you for your offer, but the regression introduced in version 1.1 is already fixed. The issue is only open to allow the original author to test the fix. If no comment is posted within a week, i will close the issue by myself.

    The development takes place on the master branch and this branch is always in a releasable state. The stable branch is the state of the latest release.

  5. dunaden001 commented on Oct 23, 2023

    @dunaden001
    Author

    Sorry for the delay, pulled and tested the tagged commit and it does appear to solve the issue.

  6. added a commit that references this issue on Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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