From 8634569de7da9d83797cdd5f322c91e8d1d138ed Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Fri, 24 Apr 2026 20:33:05 -0500 Subject: [PATCH] Fix #7998: Fix ExcludeFromDrawing filter corruption In exclude_element_from_drawing, use " + " instead of "+" when appending a GlobalId. Lark's unquoted_string regex (/[^,.=><*!\s]+/) does not exclude '"' or '+', so '"DEMOLISH"+GlobalId' was greedily matched as one token, causing wrap_value to double-quote and escape the inner quotes on the next round-trip through edit_element_filter. Adding a space forces unquoted_string to stop at whitespace, letting ESCAPED_STRING win the length tie on priority. Also replace the enable_editing_element_filter + edit_element_filter calls in ExcludeFromDrawing._execute with a direct activate_drawing call; edit_element_filter was unnecessarily re-exporting the pset and triggering the bug. Generated with the assistance of an AI coding tool. --- src/bonsai/bonsai/bim/module/drawing/operator.py | 3 +-- src/bonsai/bonsai/tool/drawing.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/drawing/operator.py b/src/bonsai/bonsai/bim/module/drawing/operator.py index 86aaf0db3b..26794ecd78 100644 --- a/src/bonsai/bonsai/bim/module/drawing/operator.py +++ b/src/bonsai/bonsai/bim/module/drawing/operator.py @@ -4039,8 +4039,7 @@ class ExcludeFromDrawing(bpy.types.Operator, tool.Ifc.Operator): if element: tool.Drawing.exclude_element_from_drawing(element, drawing) core.sync_references(tool.Ifc, tool.Collector, tool.Drawing, drawing=drawing) - bpy.ops.bim.enable_editing_element_filter(filter_mode="EXCLUDE") - bpy.ops.bim.edit_element_filter(filter_mode="EXCLUDE") + bpy.ops.bim.activate_drawing(drawing=drawing.id(), should_view_from_camera=False) class ActivateDrawingByAnnotation(bpy.types.Operator, tool.Ifc.Operator): diff --git a/src/bonsai/bonsai/tool/drawing.py b/src/bonsai/bonsai/tool/drawing.py index 75289671b4..a3c72f3757 100644 --- a/src/bonsai/bonsai/tool/drawing.py +++ b/src/bonsai/bonsai/tool/drawing.py @@ -232,7 +232,7 @@ class Drawing(bonsai.core.tool.Drawing): pset = ifcopenshell.api.pset.add_pset(ifc_file, product=drawing, name="EPset_Drawing") exclude = ifcopenshell.util.element.get_property_definition(pset, prop="Exclude") or "" if exclude: - exclude += "+" + exclude += " + " exclude += element.GlobalId ifcopenshell.api.pset.edit_pset(tool.Ifc.get(), pset=pset, properties={"Exclude": exclude})