Fix polyline tool angle lock when using XZ and YZ plane

This commit is contained in:
Bruno Perdigão
2025-02-13 14:08:55 -03:00
parent 1165ef3f33
commit 8acd5321b0
3 changed files with 8 additions and 4 deletions
+1 -1
View File
@@ -110,7 +110,7 @@ class Cad:
parameter = ( parameter = (
round(axis.z, 2) < 0 round(axis.z, 2) < 0
or (round(axis.y, 2) == 0 and round(axis.x < 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: if new_angle is not None:
rot_mat = Matrix.Rotation(new_angle, 3, axis) rot_mat = Matrix.Rotation(new_angle, 3, axis)
+4
View File
@@ -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 # 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 # 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)) 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)) 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 distance = (snap_vector - last_point).length
if distance < 0: if distance < 0:
+3 -3
View File
@@ -140,7 +140,7 @@ class Snap(bonsai.core.tool.Snap):
bpy.context.scene.BIMPolylineProperties.snap_mouse_ref.clear() bpy.context.scene.BIMPolylineProperties.snap_mouse_ref.clear()
@classmethod @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): def create_axis_line_data(rot_mat, origin):
length = 1000 length = 1000
direction = Vector((1, 0, 0)) direction = Vector((1, 0, 0))
@@ -488,10 +488,10 @@ class Snap(bonsai.core.tool.Snap):
tool_state.snap_angle = 90 tool_state.snap_angle = 90
if tool_state.lock_axis or tool_state.axis_method: if tool_state.lock_axis or tool_state.axis_method:
# Doesn't update snap_angle so that it keeps in the same axis # 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: else:
rot_intersection, tool_state.snap_angle, axis_start, axis_end = cls.snap_on_axis( 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: if rot_intersection and polyline_points: