32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import maya.cmds as cmds
|
|
from Core import SkinCluster
|
|
|
|
def export_skin_cluster():
|
|
"""
|
|
导出选中物体的蒙皮权重
|
|
- 打开文件对话框选择保存目录
|
|
- 为每个选中的物体导出蒙皮权重文件
|
|
"""
|
|
# 打开文件对话框选择保存目录
|
|
directory = cmds.fileDialog2(fileMode=2, dialogStyle=1)
|
|
|
|
# 检查是否选择了目录
|
|
if directory and cmds.file(directory[0], query=True, exists=True):
|
|
# 获取选中的物体
|
|
selection = cmds.ls(selection=True)
|
|
suffix = ".skin"
|
|
|
|
# 处理每个选中的物体
|
|
for obj in selection:
|
|
# 查找关联的蒙皮变形器
|
|
skin_cluster = cmds.findRelatedSkinCluster(obj)
|
|
|
|
# 如果存在蒙皮变形器,则导出权重
|
|
if cmds.objExists(skin_cluster):
|
|
# 构建保存路径
|
|
save_path = f"{directory[0]}/{obj}{suffix}"
|
|
# 导出权重
|
|
SkinCluster(ef=obj, export_file=save_path) |