diff --git a/src/blenderbim/blenderbim/bim/module/drawing/operator.py b/src/blenderbim/blenderbim/bim/module/drawing/operator.py index c0bf829553..d85cd2dbe9 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/operator.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/operator.py @@ -889,6 +889,21 @@ class CreateDrawing(bpy.types.Operator): ) return classes + def is_manifold(self, obj): + result = self.is_manifold_cache.get(obj.data.name, None) + if result is not None: + return result + + bm = bmesh.new() + bm.from_mesh(obj.data) + for edge in bm.edges: + if not edge.is_manifold: + bm.free() + self.is_manifold_cache[obj.data.name] = False + return False + self.is_manifold_cache[obj.data.name] = True + return True + def merge_linework_and_add_metadata(self, root): join_criteria = ifcopenshell.util.element.get_pset(self.camera_element, "EPset_Drawing", "JoinCriteria") if join_criteria: @@ -899,6 +914,7 @@ class CreateDrawing(bpy.types.Operator): group = root.findall(".//{http://www.w3.org/2000/svg}g")[0] joined_paths = {} + self.is_manifold_cache = {} ifc = tool.Ifc.get() for el in root.findall(".//{http://www.w3.org/2000/svg}g[@{http://www.ifcopenshell.org/ns}guid]"): @@ -908,6 +924,10 @@ class CreateDrawing(bpy.types.Operator): classes.append("cut") el.set("class", " ".join(classes)) + obj = tool.Ifc.get_object(element) + if not self.is_manifold(obj): + continue + # An element group will contain a bunch of paths representing the # cut of that element. However IfcOpenShell may not correctly # create closed paths. We post-process all paths with shapely to