mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +00:00
You can now flip the direction of doors and windows
This commit is contained in:
@@ -42,6 +42,7 @@ classes = (
|
|||||||
opening.AddPotentialHalfSpaceSolid,
|
opening.AddPotentialHalfSpaceSolid,
|
||||||
opening.AddPotentialOpening,
|
opening.AddPotentialOpening,
|
||||||
opening.EditOpenings,
|
opening.EditOpenings,
|
||||||
|
opening.FlipFill,
|
||||||
opening.HideBooleans,
|
opening.HideBooleans,
|
||||||
opening.HideOpenings,
|
opening.HideOpenings,
|
||||||
opening.RecalculateFill,
|
opening.RecalculateFill,
|
||||||
|
|||||||
@@ -218,6 +218,36 @@ class RecalculateFill(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
return {"FINISHED"}
|
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):
|
class AddPotentialOpening(Operator, AddObjectHelper):
|
||||||
bl_idname = "bim.add_potential_opening"
|
bl_idname = "bim.add_potential_opening"
|
||||||
bl_label = "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_SHIFT")
|
||||||
row.label(text="", icon="EVENT_G")
|
row.label(text="", icon="EVENT_G")
|
||||||
row.operator("bim.hotkey", text="Regen").hotkey = "S_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 (
|
elif AuthoringData.data["active_class"] in (
|
||||||
"IfcCableCarrierSegmentType",
|
"IfcCableCarrierSegmentType",
|
||||||
"IfcCableSegmentType",
|
"IfcCableSegmentType",
|
||||||
@@ -399,6 +404,8 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
def hotkey_S_F(self):
|
def hotkey_S_F(self):
|
||||||
if self.active_class in ("IfcWall", "IfcWallStandardCase"):
|
if self.active_class in ("IfcWall", "IfcWallStandardCase"):
|
||||||
bpy.ops.bim.flip_wall()
|
bpy.ops.bim.flip_wall()
|
||||||
|
elif self.active_class in ("IfcWindow", "IfcWindowStandardCase", "IfcDoor", "IfcDoorStandardCase"):
|
||||||
|
bpy.ops.bim.flip_fill()
|
||||||
|
|
||||||
def hotkey_S_G(self):
|
def hotkey_S_G(self):
|
||||||
if self.active_class in ("IfcWall", "IfcWallStandardCase"):
|
if self.active_class in ("IfcWall", "IfcWallStandardCase"):
|
||||||
|
|||||||
Reference in New Issue
Block a user