MetaFusion/scripts/Reference/SGBatchDelBlendShape.py
2025-01-17 02:30:36 +08:00

42 lines
1.2 KiB
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/09/24
"""
import maya.cmds as cmds
import re
def sg_batch_del_blend_shape(lod, meshes):
"""
批量删除指定LOD级别模型的混合变形节点
参数:
lod (int): LOD级别
meshes (list): 要处理的网格体名称列表
"""
# 获取指定LOD级别的所有网格体索引
mesh_indices = cmds.SGGetMeshes(lod=lod)
for mesh_index in mesh_indices:
# 获取网格体名称
mesh = cmds.SGGetMeshes(m=mesh_index)
if cmds.objExists(mesh):
# 获取LOD网格体名称
lod_mesh = cmds.SGGetMeshes(i=mesh_index)
# 使用正则表达式匹配第一个下划线前的内容
head = re.match(r'[^_]+', lod_mesh).group(0)
# 如果当前模型在要处理的列表中
if head in meshes:
# 构建混合变形节点名称
blend_shape = f"{lod_mesh}_blendShapes"
# 如果混合变形节点存在则删除
if cmds.objExists(blend_shape):
cmds.delete(blend_shape)