diff --git a/src/blenderbim/blenderbim/bim/module/model/opening.py b/src/blenderbim/blenderbim/bim/module/model/opening.py index ef7ea63bc8..f55925fa49 100644 --- a/src/blenderbim/blenderbim/bim/module/model/opening.py +++ b/src/blenderbim/blenderbim/bim/module/model/opening.py @@ -498,10 +498,12 @@ class AddBoolean(Operator, tool.Ifc.Operator): bl_label = "Add Boolean" bl_options = {"REGISTER", "UNDO"} + @classmethod + def poll(cls, context): + return len(context.selected_objects) == 2 + def _execute(self, context): props = context.scene.BIMModelProperties - if len(context.selected_objects) != 2: - return {"FINISHED"} obj1, obj2 = context.selected_objects element1 = tool.Ifc.get_entity(obj1) element2 = tool.Ifc.get_entity(obj2) @@ -546,14 +548,18 @@ class ShowBooleans(Operator, tool.Ifc.Operator, AddObjectHelper): bl_label = "Show Booleans" bl_options = {"REGISTER", "UNDO"} + @classmethod + def poll(cls, context): + obj = context.active_object + return ( + obj.data + and hasattr(obj.data, "BIMMeshProperties") + and obj.data.BIMMeshProperties.ifc_definition_id + ) + + def _execute(self, context): obj = context.active_object - if ( - not obj.data - or not hasattr(obj.data, "BIMMeshProperties") - or not obj.data.BIMMeshProperties.ifc_definition_id - ): - return {"FINISHED"} unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) representation = tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id) booleans = [] diff --git a/src/blenderbim/blenderbim/bim/module/void/ui.py b/src/blenderbim/blenderbim/bim/module/void/ui.py index fd1020fac9..d4a4bdea15 100644 --- a/src/blenderbim/blenderbim/bim/module/void/ui.py +++ b/src/blenderbim/blenderbim/bim/module/void/ui.py @@ -109,8 +109,10 @@ class BIM_PT_booleans(Panel): if context.active_object.data.BIMMeshProperties.ifc_definition_id: row = layout.row(align=True) row.label(text=f"{BooleansData.data['total_booleans']} Booleans Found") - row.operator("bim.add_boolean", text="", icon="ADD") - row.operator("bim.show_booleans", text="", icon="HIDE_OFF") + row.operator("bim.add_boolean", text="Apply Boolean", icon="ADD") + show_boolean_button = row.row(align=True) + show_boolean_button.operator("bim.show_booleans", text="", icon="HIDE_OFF") + show_boolean_button.enabled = BooleansData.data['total_booleans'] > 0 row.operator("bim.hide_booleans", text="", icon="HIDE_ON") elif context.active_object.data.BIMMeshProperties.ifc_boolean_id: row = layout.row()