From 1302a22e18641cf2fc19125ffbb4db0c3f6304a0 Mon Sep 17 00:00:00 2001 From: franMarz <58062362+franMarz@users.noreply.github.com> Date: Mon, 7 Sep 2020 01:41:46 +0200 Subject: [PATCH 1/2] Align World versions fix --- op_island_align_world.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/op_island_align_world.py b/op_island_align_world.py index b9047f6..639ed55 100644 --- a/op_island_align_world.py +++ b/op_island_align_world.py @@ -198,6 +198,10 @@ def align_island(obj, bm, uv_layers, faces, x=0, y=1, flip_x=False, flip_y=False avg_angle+=a_delta avg_angle /= n_edges + + # For some reason, bpy.ops.transform.rotate rotates in the opposite direction in Blender 2.83 compared to other versions. + if float(bpy.app.version_string[0:4]) == 2.83: + avg_angle = -avg_angle print("Edges {}x".format(n_edges)) print("Turn {:.1f}".format(avg_angle * 180/math.pi)) @@ -208,7 +212,7 @@ def align_island(obj, bm, uv_layers, faces, x=0, y=1, flip_x=False, flip_y=False loop[uv_layers].select = True bpy.context.tool_settings.transform_pivot_point = 'MEDIAN_POINT' - bpy.ops.transform.rotate(value=-avg_angle, orient_axis='Z') # minus angle; Blender uses unconventional rotation notation (positive for clockwise) + bpy.ops.transform.rotate(value=-avg_angle, orient_axis='Z', constraint_axis=(False, False, False), orient_type='GLOBAL', mirror=False, use_proportional_edit=False) def align_island_simple(obj, bm, uv_layers, faces, x=0, y=1, flip_x=False, flip_y=False): @@ -266,7 +270,7 @@ def align_island_simple(obj, bm, uv_layers, faces, x=0, y=1, flip_x=False, flip_ loop[uv_layers].select = True bpy.context.tool_settings.transform_pivot_point = 'MEDIAN_POINT' - bpy.ops.transform.rotate(value=-a_delta, orient_axis='Z') # minus angle; Blender uses unconventional rotation notation (positive for clockwise) + bpy.ops.transform.rotate(value=a_delta, orient_axis='Z') bpy.utils.register_class(op) From 240f02f6eb99497548f997c57f96fa95c136ce5b Mon Sep 17 00:00:00 2001 From: franMarz <58062362+franMarz@users.noreply.github.com> Date: Mon, 7 Sep 2020 01:48:20 +0200 Subject: [PATCH 2/2] Align World versions fix 2 --- op_island_align_world.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/op_island_align_world.py b/op_island_align_world.py index 639ed55..d98744f 100644 --- a/op_island_align_world.py +++ b/op_island_align_world.py @@ -261,6 +261,10 @@ def align_island_simple(obj, bm, uv_layers, faces, x=0, y=1, flip_x=False, flip_ a1 = math.atan2(delta_uvs.y, delta_uvs.x) a_delta = math.atan2(math.sin(a0-a1), math.cos(a0-a1)) + + # For some reason, bpy.ops.transform.rotate rotates in the opposite direction in Blender 2.83 compared to other versions. + if float(bpy.app.version_string[0:4]) == 2.83: + a_delta = -a_delta print("Turn {:.1f}".format(a_delta * 180/math.pi)) @@ -270,7 +274,7 @@ def align_island_simple(obj, bm, uv_layers, faces, x=0, y=1, flip_x=False, flip_ loop[uv_layers].select = True bpy.context.tool_settings.transform_pivot_point = 'MEDIAN_POINT' - bpy.ops.transform.rotate(value=a_delta, orient_axis='Z') + bpy.ops.transform.rotate(value=-a_delta, orient_axis='Z', constraint_axis=(False, False, False), orient_type='GLOBAL', mirror=False, use_proportional_edit=False) bpy.utils.register_class(op)