From 266236ee49398dabb2bfafc048f6fece30225289 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 23 Jan 2024 16:06:54 +1100 Subject: [PATCH] See #4241. Only use shapely to repolygonise if IfcOpenShell returns unclosed paths. Hollow cuts typically are closed paths. --- .../blenderbim/bim/module/drawing/operator.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/drawing/operator.py b/src/blenderbim/blenderbim/bim/module/drawing/operator.py index 1456d612e9..9d59c9a9fa 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/operator.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/operator.py @@ -966,17 +966,21 @@ class CreateDrawing(bpy.types.Operator): # alone (e.g. dangles, cuts, invalids). See #3421. line_strings = [] old_paths = [] + has_open_paths = False for path in el.findall("{http://www.w3.org/2000/svg}path"): for subpath in path.attrib["d"].split("M")[1:]: subpath = "M" + subpath.strip() coords = [[round(float(o), 1) for o in co[1:].split(",")] for co in subpath.split()] + if coords[0] != coords[-1]: + has_open_paths = True line_strings.append(shapely.LineString(coords)) old_paths.append(path) - unioned_line_strings = shapely.union_all(shapely.GeometryCollection(line_strings)) - if hasattr(unioned_line_strings, "geoms"): - results = shapely.polygonize_full(unioned_line_strings.geoms) - else: - results = [] + + results = [] + if has_open_paths: + unioned_line_strings = shapely.union_all(shapely.GeometryCollection(line_strings)) + if hasattr(unioned_line_strings, "geoms"): + results = shapely.polygonize_full(unioned_line_strings.geoms) # If we succeeded in generating new path geometry, remove all the # old paths and add new ones.