diff --git a/lib/stitches/fill.py b/lib/stitches/fill.py index 2c5cdffc3..9e9ff7909 100644 --- a/lib/stitches/fill.py +++ b/lib/stitches/fill.py @@ -149,14 +149,13 @@ def intersect_region_with_grating(shape, angle, row_spacing, end_row_spacing=Non res = grating_line.intersection(shape) - if (isinstance(res, shapely.geometry.MultiLineString) or isinstance(res, shapely.geometry.GeometryCollection)): - runs = [line_string.coords for line_string in res.geoms if isinstance(line_string, shapely.geometry.LineString)] + if res.geom_type in ["MultiLineString", "GeometryCollection"]: + runs = [line_string.coords for line_string in res.geoms if line_string.geom_type == "LineString"] + elif res.geom_type in ["Point", "MultiPoint"] or res.is_empty: + # ignore if we intersected at a single point or no points + runs = [] else: - if res.is_empty or len(res.coords) == 1: - # ignore if we intersected at a single point or no points - runs = [] - else: - runs = [res.coords] + runs = [res.coords] if runs: runs.sort(key=lambda seg: (InkstitchPoint(*seg[0]) - upper_left).length())