From 130b569f6f952d55de7b3f5a875a6b7f7fbfadda Mon Sep 17 00:00:00 2001 From: Robin Quint Date: Sat, 2 Aug 2025 19:18:00 +0200 Subject: [PATCH] Doors are now placed on the side of the wall that was snapped to --- src/bonsai/bonsai/bim/module/model/opening.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/model/opening.py b/src/bonsai/bonsai/bim/module/model/opening.py index 4a16bee5af..ac1a75cc92 100644 --- a/src/bonsai/bonsai/bim/module/model/opening.py +++ b/src/bonsai/bonsai/bim/module/model/opening.py @@ -39,7 +39,7 @@ import numpy as np import shapely from bpy.types import Operator, SpaceView3D from gpu_extras.batch import batch_for_shader -from mathutils import Matrix, Vector +from mathutils import Euler, Matrix, Vector import bonsai.core.geometry import bonsai.tool as tool @@ -298,9 +298,16 @@ class FilledOpeningGenerator: new_matrix.translation.x = point_on_base_axis.x new_matrix.translation.y = point_on_base_axis.y else: - new_matrix.translation.x = point_on_side_axis.x - new_matrix.translation.y = point_on_side_axis.y - new_matrix = new_matrix @ Matrix.Rotation(radians(180.0), 4, "Z") + filling_min_x = min([p[0] for p in filling_obj.bound_box]) + filling_max_x = max([p[0] for p in filling_obj.bound_box]) + + # offset that results in the same x extents when the model is rotated 180 degrees + filling_opposite_x = filling_max_x + filling_min_x + + offset_dir = voided_obj.matrix_world @ Vector((filling_opposite_x, 0, 0, 0)) + new_matrix.translation.x = point_on_side_axis.x + offset_dir.x + new_matrix.translation.y = point_on_side_axis.y + offset_dir.y + new_matrix = new_matrix @ Euler((0, 0, radians(180.0))).to_matrix().to_4x4() if should_set_z_level: if filling.is_a("IfcDoor"):