diff --git a/src/blenderbim/blenderbim/bim/module/model/__init__.py b/src/blenderbim/blenderbim/bim/module/model/__init__.py index 5d4a2009e6..04aa2eb38b 100644 --- a/src/blenderbim/blenderbim/bim/module/model/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/model/__init__.py @@ -42,6 +42,7 @@ classes = ( opening.AddPotentialHalfSpaceSolid, opening.AddPotentialOpening, opening.EditOpenings, + opening.FlipFill, opening.HideBooleans, opening.HideOpenings, opening.RecalculateFill, diff --git a/src/blenderbim/blenderbim/bim/module/model/opening.py b/src/blenderbim/blenderbim/bim/module/model/opening.py index 0d85476eff..602c6cf2a5 100644 --- a/src/blenderbim/blenderbim/bim/module/model/opening.py +++ b/src/blenderbim/blenderbim/bim/module/model/opening.py @@ -218,6 +218,36 @@ class RecalculateFill(bpy.types.Operator, tool.Ifc.Operator): return {"FINISHED"} +class FlipFill(bpy.types.Operator, tool.Ifc.Operator): + bl_idname = "bim.flip_fill" + bl_label = "Flip Fill" + bl_options = {"REGISTER", "UNDO"} + + @classmethod + def poll(cls, context): + return context.selected_objects + + def _execute(self, context): + for obj in context.selected_objects: + element = tool.Ifc.get_entity(obj) + if not element or not element.FillsVoids: + continue + + flip_matrix = Matrix.Rotation(pi, 4, "Z") + + bottom_left = obj.matrix_world @ Vector(obj.bound_box[0]) + top_right = obj.matrix_world @ Vector(obj.bound_box[6]) + center = obj.matrix_world.col[3].to_3d().copy() + center_offset = center - bottom_left + flipped_center = top_right - center_offset + + obj.matrix_world = obj.matrix_world @ flip_matrix + obj.matrix_world.col[3][0] = flipped_center[0] + obj.matrix_world.col[3][1] = flipped_center[1] + bpy.context.view_layer.update() + return {"FINISHED"} + + class AddPotentialOpening(Operator, AddObjectHelper): bl_idname = "bim.add_potential_opening" bl_label = "Add Potential Opening" diff --git a/src/blenderbim/blenderbim/bim/module/model/workspace.py b/src/blenderbim/blenderbim/bim/module/model/workspace.py index 288b51c3d6..ba01fd2c78 100644 --- a/src/blenderbim/blenderbim/bim/module/model/workspace.py +++ b/src/blenderbim/blenderbim/bim/module/model/workspace.py @@ -213,6 +213,11 @@ class BimToolUI: row.label(text="", icon="EVENT_SHIFT") row.label(text="", icon="EVENT_G") row.operator("bim.hotkey", text="Regen").hotkey = "S_G" + + row = cls.layout.row(align=True) + row.label(text="", icon="EVENT_SHIFT") + row.label(text="", icon="EVENT_F") + row.operator("bim.hotkey", text="Flip").hotkey = "S_F" elif AuthoringData.data["active_class"] in ( "IfcCableCarrierSegmentType", "IfcCableSegmentType", @@ -399,6 +404,8 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator): def hotkey_S_F(self): if self.active_class in ("IfcWall", "IfcWallStandardCase"): bpy.ops.bim.flip_wall() + elif self.active_class in ("IfcWindow", "IfcWindowStandardCase", "IfcDoor", "IfcDoorStandardCase"): + bpy.ops.bim.flip_fill() def hotkey_S_G(self): if self.active_class in ("IfcWall", "IfcWallStandardCase"):