forked from franMarz/TexTools-Blender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
op_uv_channel_remove.py
41 lines (31 loc) · 1.13 KB
/
op_uv_channel_remove.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
import bpy
from . import utilities_uv
class op(bpy.types.Operator):
bl_idname = "uv.textools_uv_channel_remove"
bl_label = "Remove UV Channel"
bl_description = "Remove the active UV channel from all the selected Objects"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
if not bpy.context.active_object:
return False
if bpy.context.active_object.type != 'MESH':
return False
if not bpy.context.object.data.uv_layers:
return False
return True
def execute(self, context):
premode = bpy.context.active_object.mode
utilities_uv.multi_object_loop(removeuvs, self, context)
bpy.ops.object.mode_set(mode=premode)
return {'FINISHED'}
def removeuvs(self, context):
if bpy.context.object.data.uv_layers:
# Remove active UV channel
bpy.context.active_object.data.uv_layers.remove(bpy.context.object.data.uv_layers.active)
# Get current index
index = len(bpy.context.object.data.uv_layers)-1
if index >= 0:
bpy.context.object.data.uv_layers.active_index = index
bpy.context.scene.texToolsSettings.uv_channel = str(index)
bpy.context.active_object.data.uv_layers[0].active_render = True