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.
This commit is contained in:
Ryan Schultz
2026-04-24 20:33:05 -05:00
parent 02ddedd3e6
commit 8634569de7
2 changed files with 2 additions and 3 deletions
@@ -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):
+1 -1
View File
@@ -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})