1 Star 0 Fork 0

tangyin025/TexTools-Blender

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
op_uv_channel_add.py 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
franMarz 提交于 2023-12-25 17:55 . Improve instances support
import bpy
from . import utilities_ui
from . import utilities_uv
class op(bpy.types.Operator):
bl_idname = "uv.textools_uv_channel_add"
bl_label = "Add UV Channel"
bl_description = "Add a new UV channel to 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
return True
def execute(self, context):
premode = bpy.context.active_object.mode
utilities_uv.multi_object_loop(adduvs, self, context)
bpy.ops.object.mode_set(mode=premode)
return {'FINISHED'}
def adduvs(self, context):
if len( bpy.context.object.data.uv_layers ) == 0:
bpy.context.active_object.data.uv_layers.new(name="UVMap")
else:
# Add new UV channel based on last
#bpy.ops.mesh.uv_texture_add()
name = "UVMap" + str(len(bpy.context.active_object.data.uv_layers)+1)
bpy.context.active_object.data.uv_layers.new(name=name)
# Get current index
index = len(bpy.context.object.data.uv_layers)-1
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
bpy.utils.register_class(op)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tangyin025/TexTools-Blender.git
[email protected]:tangyin025/TexTools-Blender.git
tangyin025
TexTools-Blender
TexTools-Blender
master

搜索帮助