41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
#!/usr/bin/env python
|
||
# -*- coding: utf-8 -*-
|
||
|
||
import os
|
||
import maya.cmds as cmds
|
||
from scripts.utils.Core import GetMeshes, Descriptor, FindSkinCluster, SkinCluster
|
||
|
||
def fast_unbind_skin_cluster():
|
||
"""
|
||
快速解除蒙皮绑定
|
||
- 遍历所有网格
|
||
- 导出蒙皮权重
|
||
- 解除蒙皮绑定
|
||
"""
|
||
# 遍历所有网格(0-53)
|
||
for i in range(54):
|
||
# 获取网格名称
|
||
mesh = GetMeshes(m=i)
|
||
|
||
# 检查网格是否存在
|
||
if not cmds.objExists(mesh):
|
||
continue
|
||
|
||
# 查找蒙皮变形器
|
||
skin_cluster = FindSkinCluster(mesh)
|
||
|
||
# 如果存在蒙皮变形器
|
||
if cmds.objExists(skin_cluster):
|
||
# 构建保存路径
|
||
path = os.path.join(Descriptor(p=True), "skin_buffer")
|
||
skin_file = os.path.join(path, f"{mesh}.skin")
|
||
|
||
# 如果目录不存在则创建
|
||
if not os.path.exists(path):
|
||
os.makedirs(path)
|
||
|
||
# 导出蒙皮权重
|
||
SkinCluster(mesh=mesh, export_file=skin_file)
|
||
|
||
# 解除蒙皮绑定
|
||
cmds.skinCluster(mesh, edit=True, unbind=True) |