42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import maya.cmds as cmds
|
|
import sys
|
|
import importlib
|
|
|
|
def run():
|
|
# 获取选中的对象
|
|
selected = cmds.ls(selection=True, transforms=True)
|
|
|
|
# 检查是否选择了两个对象
|
|
if len(selected) != 2:
|
|
raise RuntimeError(f"请选择两个多边形对象!")
|
|
|
|
# 检查每个选中对象的类型
|
|
for obj in selected:
|
|
shapes = cmds.listRelatives(obj, shapes=True)
|
|
for shape in shapes:
|
|
if cmds.nodeType(shape) != "mesh":
|
|
raise RuntimeError(f"选中的几何体不是多边形对象!")
|
|
|
|
# 检查第一个对象是否绑定了蒙皮
|
|
shapes = cmds.listRelatives(selected[0], shapes=True)
|
|
skin = cmds.listConnections(shapes[0], type="skinCluster")
|
|
if not skin:
|
|
raise RuntimeError(f"第一个选中的对象没有绑定蒙皮簇!")
|
|
|
|
# 执行 extractDeltas 命令
|
|
cmds.extractDeltas(s=selected[0], c=selected[1])
|
|
|
|
# 选择第二个对象
|
|
cmds.select(selected[1], replace=True)
|
|
|
|
# 导入并运行 bsIndex
|
|
sys.path.append('C:/Arts and Spells/Metapipe Studio 1.3.0')
|
|
import bsIndex
|
|
importlib.reload(bsIndex)
|
|
bsIndex.calc()
|
|
|
|
if __name__ == "__main__":
|
|
run() |