Improve slightly the boolean interface in mesh properties editor

This commit is contained in:
Gorgious56
2023-07-13 14:52:00 +02:00
parent 60b06bbc44
commit 8339d04326
2 changed files with 18 additions and 10 deletions
@@ -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 = []
@@ -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()