diff --git a/src/bonsai/bonsai/bim/module/model/decorator.py b/src/bonsai/bonsai/bim/module/model/decorator.py index 7728da27da..03b5274764 100644 --- a/src/bonsai/bonsai/bim/module/model/decorator.py +++ b/src/bonsai/bonsai/bim/module/model/decorator.py @@ -1554,16 +1554,26 @@ class ProductDecorator(tool.Blender.ViewportDecorator): axis_side = axes["side"] point_on_base_axis = tool.Cad.point_on_edge(mouse_point, axis_base) point_on_side_axis = tool.Cad.point_on_edge(mouse_point, axis_side) + # Match FilledOpeningGenerator.generate: the filling faces the + # wall body from whichever face is snapped, so a NEGATIVE + # direction sense inverts which face needs the 180 degree turn. + flipped_wall = layers["direction_sense"] == "NEGATIVE" if (point_on_base_axis - mouse_point).length_squared <= (point_on_side_axis - mouse_point).length_squared: - # mouse is snapped to the base axis, the preview looks exactly like the placed door / window - rot_mat = snap_obj.matrix_world + # mouse is snapped to the base axis + rotate_filling = flipped_wall else: - # mouse is snapped to the side axis, the preview is inverted, rotate it now and correct x position later + # mouse is snapped to the side axis + rotate_filling = not flipped_wall + if rotate_filling: + # the preview is inverted, rotate it now and correct x position later rot_mat = ( (snap_obj.matrix_world.to_quaternion() @ Quaternion(Vector((0, 0, 1)), radians(180))) .to_matrix() .to_4x4() ) + else: + # the preview looks exactly like the placed door / window + rot_mat = snap_obj.matrix_world mouse_point.z = snap_obj.matrix_world.translation.z diff --git a/src/bonsai/bonsai/bim/module/model/opening.py b/src/bonsai/bonsai/bim/module/model/opening.py index 0508883c35..a6ffc51cf5 100644 --- a/src/bonsai/bonsai/bim/module/model/opening.py +++ b/src/bonsai/bonsai/bim/module/model/opening.py @@ -303,12 +303,19 @@ class FilledOpeningGenerator: new_matrix = voided_obj.matrix_world.copy() point_on_base_axis = tool.Cad.point_on_edge(target, axis_base) point_on_side_axis = tool.Cad.point_on_edge(target, axis_side) + # The filling faces the wall body from whichever face was + # clicked, so a NEGATIVE direction sense (body on the wall's + # local -Y) inverts which face needs the 180 degree turn. + flipped_wall = layers["direction_sense"] == "NEGATIVE" if (point_on_base_axis - target).length <= (point_on_side_axis - target).length: new_matrix.translation.x = point_on_base_axis.x new_matrix.translation.y = point_on_base_axis.y + rotate_filling = flipped_wall else: new_matrix.translation.x = point_on_side_axis.x new_matrix.translation.y = point_on_side_axis.y + rotate_filling = not flipped_wall + if rotate_filling: new_matrix = new_matrix @ Matrix.Rotation(radians(180.0), 4, "Z") if should_set_z_level: