copyMultSkin

 avatar
unknown
python
3 years ago
1.6 kB
4
Indexable
import pymel.core as pm
'''
copySkinWeights  -noMirror -surfaceAssociation closestComponent -influenceAssociation closestJoint;
pm.copySkinWeights( ss='skinCluster1', ds='skinCluster1', mirrorMode='YZ', mirrorInverse=True )

'''
##select source then target grp
sel = pm.selected()
targetGrp = sel[1] 
sourceGrp = sel[0] 

sourceObjs = [ i.getParent() for i in sourceGrp.listRelatives(ad = True,type = 'mesh') if 'Orig' not in i.nodeName() and i.intermediateObject.get() != 1 ]
targetObjs =  [ i.getParent() for i in targetGrp.listRelatives(ad = True,type = 'mesh') if 'Orig' not in i.nodeName() and i.intermediateObject.get() != 1 ]

for s in sourceObjs:
    for t in targetObjs:
        
        if s.nodeName().split(':')[-1] == t.nodeName().split(':')[-1]:
            print 'MATCHING >>>> ' + s + ' >>>>>> ' + t
            relShapes = s.listRelatives(c = True)
            for i in relShapes:
                try:
                    skinSource = i.listHistory(type = 'skinCluster')[0]
                except:
                    pass

            relShapes = t.listRelatives(c = True)
            for i in relShapes:
                try:
                    skinTarget = i.listHistory(type = 'skinCluster')[0]
                except:
                    pass
            if skinTarget and skinSource:
                pm.copySkinWeights( ss= skinSource.nodeName(), ds=skinTarget.nodeName(), noMirror = True, surfaceAssociation  = 'closestComponent' , influenceAssociation = 'closestJoint')
                print ('COPYING WEIGHTS FROM THIS SKIN CLUSTER >>>> ' + skinTarget + ' >>>>>>>TO THIS >>>> ' + skinSource)
Editor is loading...