-
Notifications
You must be signed in to change notification settings - Fork 142
/
Copy pathop_island_rotate_90.py
44 lines (33 loc) · 1.3 KB
/
op_island_rotate_90.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import bpy
from . import settings
class op(bpy.types.Operator):
bl_idname = "uv.textools_island_rotate_90"
bl_label = "Rotate 90 degrees"
bl_description = "Rotate the selection 90 degrees left or right around the global Rotation/Scaling Pivot"
bl_options = {'REGISTER', 'UNDO'}
angle : bpy.props.FloatProperty(name="Angle", options={'HIDDEN'})
@classmethod
def poll(cls, context):
if bpy.context.area.ui_type != 'UV':
return False
if not bpy.context.active_object:
return False
if bpy.context.active_object.type != 'MESH':
return False
if bpy.context.active_object.mode != 'EDIT':
return False
if not bpy.context.object.data.uv_layers:
return False
return True
def execute(self, context):
sync = bpy.context.scene.tool_settings.use_uv_select_sync
if sync:
selection_mode = tuple(bpy.context.scene.tool_settings.mesh_select_mode)
bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE')
angle = - self.angle
if settings.bversion == 2.83 or settings.bversion == 2.91:
angle = -angle
bpy.ops.transform.rotate(value=-angle, orient_axis='Z', constraint_axis=(False, False, False), use_proportional_edit=False)
if sync:
bpy.context.scene.tool_settings.mesh_select_mode = selection_mode
return {'FINISHED'}