# add copySkinClusterSettings(skin, skin2) #where skin is the source skinCluster name and skin2 is the target skinCluster name def copySkinClusterSettings(skin, skin2): ''' does not copy weights! just the attributes below, it uses one function for simple atributes and a different one for TdataCompond wich is used by the blendWeights attribute ''' attrs = ['skinningMethod', 'useComponents', 'deformUserNormals', 'maintainMaxInfluences', 'maxInfluences', 'normalizeWeights', 'blendWeights'] vtxCount = getVtxCountFromSkinCLuster(skin) for a in attrs: try: typ = mc.getAttr(skin+'.'+a, typ=True) if typ =='TdataCompound': copyMultiAttr(src=skin, dst=skin2, attr=a,vtxCount=vtxCount) else: copyAttr(src=skin, dst=skin2, attr=a) except Exception,e: print 'cant copy attr %s because %s' % (a, e) def getVtxCountFromSkinCLuster(skin): return len(mc.getAttr(skin+'.weightList', mi=1)) def copyAttr(src, dst, attr): value = mc.getAttr(src+'.'+attr) mc.setAttr(dst+'.'+attr, value) def copyMultiAttr(src, dst, attr, vtxCount): #attr = 'blendWeights' values = mc.getAttr(src+'.'+attr)[0] indices = mc.getAttr(src+'.'+attr, mi=True) for i,v in zip(indices, values): mc.setAttr('%s.%s[%s]' % (dst,attr,i), v) #zero out others for i in range(vtxCount): if i in indices: continue mc.setAttr('%s.%s[%s]' % (dst,attr,i), 0.0)