See #5972. You can now select booleans recursively.

This commit is contained in:
Dion Moult
2025-01-19 13:54:35 +11:00
parent 4152641d1f
commit 046f7cbfd2
4 changed files with 43 additions and 3 deletions
@@ -2737,6 +2737,7 @@ class ImportRepresentationItems(bpy.types.Operator, tool.Ifc.Operator):
new = props.item_objs.add()
new.obj = item_obj
new.is_boolean = item_id in boolean_ids
new.ifc_definition_id = item_id
tool.Geometry.import_item(item_obj)
tool.Geometry.import_item_attributes(item_obj)
@@ -79,19 +79,20 @@ classes = (
opening.AddBoolean,
opening.AddPotentialHalfSpaceSolid,
opening.AddPotentialOpening,
opening.EditOpenings,
opening.CloneOpening,
opening.UpdateOpeningsFocus,
opening.EditOpenings,
opening.FlipFill,
opening.HideBooleans,
opening.HideAllOpenings,
opening.HideBooleans,
opening.HideOpenings,
opening.PurgeUnusedOpenings,
opening.RecalculateFill,
opening.RemoveBoolean,
opening.RemoveBooleans,
opening.SelectBoolean,
opening.ShowBooleans,
opening.ShowOpenings,
opening.UpdateOpeningsFocus,
profile.ChangeCardinalPoint,
profile.ChangeProfileDepth,
profile.DisableEditingExtrusionAxis,
@@ -1165,6 +1165,43 @@ class RemoveBoolean(Operator, tool.Ifc.Operator):
tool.Geometry.reload_representation(rep_obj)
class SelectBoolean(Operator):
bl_idname = "bim.select_boolean"
bl_label = "Remove Boolean"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Selects operands of the active boolean\nSHIFT-CLICK to select all operands recursively"
is_recursive: bpy.props.BoolProperty(name="Is Recursive", default=False, options={"SKIP_SAVE"})
@classmethod
def poll(cls, context):
props = context.scene.BIMBooleanProperties
return props.active_boolean
def invoke(self, context, event):
if event.type == "LEFTMOUSE" and event.shift:
self.is_recursive = True
return self.execute(context)
def execute(self, context):
props = context.scene.BIMBooleanProperties
queue = [tool.Ifc.get().by_id(props.active_boolean.ifc_definition_id)]
items = {i.ifc_definition_id: i.obj for i in context.scene.BIMGeometryProperties.item_objs}
while queue:
item = queue.pop()
if item.is_a("IfcBooleanResult"):
if self.is_recursive:
queue.append(item.FirstOperand)
queue.append(item.SecondOperand)
else:
if obj := items.get(item.FirstOperand.id()):
tool.Blender.select_object(obj)
if obj := items.get(item.SecondOperand.id()):
tool.Blender.select_object(obj)
elif obj := items.get(item.id()):
tool.Blender.select_object(obj)
return {"FINISHED"}
# TODO: merge with ProfileDecorator?
class DecorationsHandler:
installed = None
+1
View File
@@ -178,6 +178,7 @@ class BIM_PT_booleans(Panel):
row = layout.row(align=True)
row.alignment = "RIGHT"
row.operator("bim.select_boolean", text="", icon="RESTRICT_SELECT_OFF")
row.operator("bim.remove_boolean", text="", icon="X")
self.layout.template_list("BIM_UL_booleans", "", props, "booleans", props, "active_boolean_index")