mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 18:57:17 +00:00
Improve slightly the boolean interface in mesh properties editor
This commit is contained in:
@@ -498,10 +498,12 @@ class AddBoolean(Operator, tool.Ifc.Operator):
|
|||||||
bl_label = "Add Boolean"
|
bl_label = "Add Boolean"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return len(context.selected_objects) == 2
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
props = context.scene.BIMModelProperties
|
props = context.scene.BIMModelProperties
|
||||||
if len(context.selected_objects) != 2:
|
|
||||||
return {"FINISHED"}
|
|
||||||
obj1, obj2 = context.selected_objects
|
obj1, obj2 = context.selected_objects
|
||||||
element1 = tool.Ifc.get_entity(obj1)
|
element1 = tool.Ifc.get_entity(obj1)
|
||||||
element2 = tool.Ifc.get_entity(obj2)
|
element2 = tool.Ifc.get_entity(obj2)
|
||||||
@@ -546,14 +548,18 @@ class ShowBooleans(Operator, tool.Ifc.Operator, AddObjectHelper):
|
|||||||
bl_label = "Show Booleans"
|
bl_label = "Show Booleans"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
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):
|
def _execute(self, context):
|
||||||
obj = context.active_object
|
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())
|
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
representation = tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
|
representation = tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
|
||||||
booleans = []
|
booleans = []
|
||||||
|
|||||||
@@ -109,8 +109,10 @@ class BIM_PT_booleans(Panel):
|
|||||||
if context.active_object.data.BIMMeshProperties.ifc_definition_id:
|
if context.active_object.data.BIMMeshProperties.ifc_definition_id:
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.label(text=f"{BooleansData.data['total_booleans']} Booleans Found")
|
row.label(text=f"{BooleansData.data['total_booleans']} Booleans Found")
|
||||||
row.operator("bim.add_boolean", text="", icon="ADD")
|
row.operator("bim.add_boolean", text="Apply Boolean", icon="ADD")
|
||||||
row.operator("bim.show_booleans", text="", icon="HIDE_OFF")
|
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")
|
row.operator("bim.hide_booleans", text="", icon="HIDE_ON")
|
||||||
elif context.active_object.data.BIMMeshProperties.ifc_boolean_id:
|
elif context.active_object.data.BIMMeshProperties.ifc_boolean_id:
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
|||||||
Reference in New Issue
Block a user