You can now flip the direction of doors and windows

This commit is contained in:
Dion Moult
2022-10-16 23:49:39 +11:00
parent 81d80ee415
commit 90f1a179bc
3 changed files with 38 additions and 0 deletions
@@ -42,6 +42,7 @@ classes = (
opening.AddPotentialHalfSpaceSolid,
opening.AddPotentialOpening,
opening.EditOpenings,
opening.FlipFill,
opening.HideBooleans,
opening.HideOpenings,
opening.RecalculateFill,
@@ -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"
@@ -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"):