MetaFusion/scripts/utils/BatchDelBlendShape.py
2025-02-07 05:10:30 +08:00

37 lines
1.1 KiB
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import maya.cmds as cmds
import re
from Core import GetMeshes
def batch_del_blend_shape(lod, meshes):
"""
批量删除指定LOD级别模型的混合变形节点
参数:
lod (int): LOD级别
meshes (list): 要处理的网格体名称列表
"""
# 获取指定LOD级别的所有网格体索引
mesh_indices = GetMeshes(lod=lod)
for mesh_index in mesh_indices:
# 获取网格体名称
mesh = GetMeshes(m=mesh_index)
if cmds.objExists(mesh):
# 获取LOD网格体名称
lod_mesh = GetMeshes(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)