1 Star 0 Fork 0

tangyin025/TexTools-Blender

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
op_texture_preview_cleanup.py 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
franMarz 提交于 2023-12-30 04:15 . Enhanced Checker Maps, Preview Texture
import bpy
class op(bpy.types.Operator):
bl_idname = "uv.textools_texture_preview_cleanup"
bl_label = "Texture Preview Cleanup"
bl_description = "Remove and unlink texture preview data from the selected Objects; + Alt , it's applied to all Objects in the Blendfile"
bl_options = {'REGISTER', 'UNDO'}
bool_all: bpy.props.BoolProperty(name="On all Objects", default=False)
def invoke(self, context, event):
self.bool_all = event.alt
self.execute(context)
return {'FINISHED'}
def execute(self, context):
premode = bpy.context.active_object.mode
if self.bool_all:
group = {ob for ob in bpy.data.objects if ob.type == 'MESH'}
else:
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
group = {ob for ob in bpy.context.objects_in_mode_unique_data if ob.type == 'MESH' and ob.select_get()}
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
for obj in group:
if obj.modifiers:
for m in obj.modifiers:
if m.name == 'TT-material-override':
obj.modifiers.remove(m)
for nodegroup in bpy.data.node_groups:
if nodegroup and 'TT-material-override' in nodegroup.name:
if not nodegroup.users:
bpy.data.node_groups.remove(nodegroup, do_unlink=True)
for material in bpy.data.materials:
if material and 'TT_material_override' in material.name:
if not material.users:
bpy.data.materials.remove(material, do_unlink=True)
bpy.ops.object.mode_set(mode=premode)
return {'FINISHED'}
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

搜索帮助