From 8acd5321b0c8fc57569a8b31f331eb8b5cae7926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Perdig=C3=A3o?= Date: Thu, 13 Feb 2025 14:08:55 -0300 Subject: [PATCH] Fix polyline tool angle lock when using XZ and YZ plane --- src/bonsai/bonsai/tool/cad.py | 2 +- src/bonsai/bonsai/tool/polyline.py | 4 ++++ src/bonsai/bonsai/tool/snap.py | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/bonsai/bonsai/tool/cad.py b/src/bonsai/bonsai/tool/cad.py index 36d97fbd09..9812497967 100644 --- a/src/bonsai/bonsai/tool/cad.py +++ b/src/bonsai/bonsai/tool/cad.py @@ -110,7 +110,7 @@ class Cad: parameter = ( round(axis.z, 2) < 0 or (round(axis.y, 2) == 0 and round(axis.x < 0)) - or (round(axis.x, 2) == 0 and round(axis.y < 0)) + or (round(axis.x, 2) == 0 and round(axis.y > 0)) ) if new_angle is not None: rot_mat = Matrix.Rotation(new_angle, 3, axis) diff --git a/src/bonsai/bonsai/tool/polyline.py b/src/bonsai/bonsai/tool/polyline.py index a3585c5a9d..17733c3392 100644 --- a/src/bonsai/bonsai/tool/polyline.py +++ b/src/bonsai/bonsai/tool/polyline.py @@ -155,8 +155,12 @@ class Polyline(bonsai.core.tool.Polyline): # Creates a fake "second to last" point away from the first point but in the same x axis # this allows to calculate the angle relative to x axis when there is only one point second_to_last_point = Vector((last_point.x + 1000, last_point.y, last_point.z)) + if tool_state.plane_method == "YZ": + second_to_last_point = Vector((last_point.x, last_point.y + 1000, last_point.z)) world_second_to_last_point = Vector((last_point.x + 1000, last_point.y, last_point.z)) + if tool_state.plane_method == "YZ": + world_second_to_last_point = Vector((last_point.x, last_point.y + 1000, last_point.z)) distance = (snap_vector - last_point).length if distance < 0: diff --git a/src/bonsai/bonsai/tool/snap.py b/src/bonsai/bonsai/tool/snap.py index 27c97a86f5..b083c87bd4 100644 --- a/src/bonsai/bonsai/tool/snap.py +++ b/src/bonsai/bonsai/tool/snap.py @@ -140,7 +140,7 @@ class Snap(bonsai.core.tool.Snap): bpy.context.scene.BIMPolylineProperties.snap_mouse_ref.clear() @classmethod - def snap_on_axis(cls, intersection, tool_state, lock_angle=False): + def snap_on_axis(cls, intersection, tool_state): def create_axis_line_data(rot_mat, origin): length = 1000 direction = Vector((1, 0, 0)) @@ -488,10 +488,10 @@ class Snap(bonsai.core.tool.Snap): tool_state.snap_angle = 90 if tool_state.lock_axis or tool_state.axis_method: # Doesn't update snap_angle so that it keeps in the same axis - rot_intersection, _, axis_start, axis_end = cls.snap_on_axis(intersection, tool_state, True) + rot_intersection, _, axis_start, axis_end = cls.snap_on_axis(intersection, tool_state) else: rot_intersection, tool_state.snap_angle, axis_start, axis_end = cls.snap_on_axis( - intersection, tool_state, False + intersection, tool_state ) if rot_intersection and polyline_points: