From 249e68f16395b5b273466930dd21ffefc0ac512a Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Mon, 12 Jan 2026 19:37:25 -0600 Subject: [PATCH] fix to https://github.com/IfcOpenShell/IfcOpenShell/commit/7f87f1fb89fb001320223a4d85e6267f342bf13c: have rotation around the object's origin, not the world origin --- src/bonsai/bonsai/bim/module/model/wall.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/model/wall.py b/src/bonsai/bonsai/bim/module/model/wall.py index d894aa71d1..0d0b88339e 100644 --- a/src/bonsai/bonsai/bim/module/model/wall.py +++ b/src/bonsai/bonsai/bim/module/model/wall.py @@ -575,10 +575,20 @@ class ChangeExtrusionXAngle(bpy.types.Operator, tool.Ifc.Operator): rotation_axis.normalize() dot_product = expected_new_world_direction.dot(current_world_direction) angle = acos(min(max(dot_product, -1), 1)) - - # Create and apply rotation matrix + + # Rotate around object's own origin + # Decompose the matrix to get translation, rotation, scale + translation, rotation, scale = obj.matrix_world.decompose() + + # Create rotation matrix and convert to quaternion rotation_matrix = Matrix.Rotation(angle, 4, rotation_axis) - obj.matrix_world = rotation_matrix @ obj.matrix_world + rotation_quat = rotation_matrix.to_quaternion() + + # Apply rotation to existing rotation (quaternion multiplication) + new_rotation = rotation_quat @ rotation + + # Reconstruct matrix_world with same translation, new rotation, same scale + obj.matrix_world = Matrix.Translation(translation) @ new_rotation.to_matrix().to_4x4() @ Matrix.Scale(1, 4) bpy.context.view_layer.update() bonsai.core.geometry.switch_representation(