是不是有时候盔甲很多很碎头很大,用代理一个个拷贝很麻烦吧
用下面代码直接运行进行一对多或者一对一拷贝
第一个先选择参考物体,加选其他一堆有的没的有权重或没权重的物体执行一键拷贝,就可以啦
以下是源码送上,带走吧
------------------------
#! -*- coding:utf -8 -*-
#author:liubingdong
#date:20190427
import maya.cmds as mc
import maya.mel as mel
#一对多拷贝权重
allElement=mc.ls(sl=1)
for a in range(1,len(allElement)):
canKao=allElement[0]
currentObj=allElement[a]
skinnode = mel.eval(' findRelatedSkinCluster %s'%canKao)
if skinnode:
canKaoGuge=mc.skinCluster(skinnode,q=1,inf=1)
skinnode_new = mel.eval(' findRelatedSkinCluster %s'%currentObj)
if skinnode_new:
zuiZhongGuGe=mc.skinCluster(skinnode_new,q=1,inf=1)
if zuiZhongGuGe and canKaoGuge:
if canKaoGuge!=zuiZhongGuGe:
#skinCluster -e -dr 4 -lw true -wt 0 -ai joint1 skinCluster142;
newNeedAdd=[]
for eachList in canKaoGuge:
if eachList not in zuiZhongGuGe:
newNeedAdd.append(eachList)
if newNeedAdd!=[]:
for eachNeedAdd in newNeedAdd:
mc.skinCluster( skinnode_new,e=1, lw=1 , wt= 0,ai= eachNeedAdd )
else:
#蒙皮
mc.skinCluster(canKaoGuge, currentObj,rui=0,tsb=True)
#拷贝权重
mc.select(cl=1)
mc.select(canKao)
mc.select(currentObj,add=1)
mel.eval('copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation oneToOne -influenceAssociation oneToOne -influenceAssociation oneToOne;')
print ('\n已经拷贝.............',currentObj)
-----------------------------
有任何问题联系我:27971533