top of page

Transfer Skinning Via Namespaces

jasondobra

Hi peeps, its been a while today is a public holiday so time for some blogging.

Namespaces useful!

So heres a nice little script that allows transferring multiple weights via the name space in the import options.

Everybody has a transfer skin tool this one works really well in our current pipeline. If your model updates come with namespace feel free to use. It will save some time in the production for other things.







Below is the code:


import maya.cmds as mc 

def find_matching_reference_geo(selections):
    for selection in selections: 
    	number_of_ns = selection.rpartition(':')
        if len(number_of_ns) > 1:
            namespace = number_of_ns[0]
        else:
            return
        new_name = selection.replace(namespace + ':', ' ')
        mc.select(cl=True)
        source_geoShape = new_name
        target_geoShape = selection
	mc.select(source_geoShape, target_geoShape)
        influences = copy_joint_influences(source_geoShape, target_geoShape)

def copy_joint_influences(source, destination):

    try:
        sourceSkin = mel.eval('findRelatedSkinCluster{0} '.format(source))
	influences = mc.skinCluster(sourceSkin,query=True,inf=True)
	mc.skinCluster(influences,destination,tsb=True)
	destSkin = mel.eval('findRelatedSkinCluster ' + destination)
	mc.copySkinWeights( ss = sourceSkin, ds = destSkin, noMirror = True, surfaceAssociation = 'closestPoint', influenceAssociation = 'closestJoint' )
	mc.skinCluster( destSkin, forceNormalizeWeights=True, e = True )
     except:
        mc.warning('skipping: {0} already skinned '.format(destination))
        
if __name__ == '__main__':
    find_matching_reference_geo(mc.ls(sl=True))

    

     If you need anything feel free to get in contact. or leave a comment below :)

Jason


70 views0 comments

Recent Posts

See All

Commentaires


bottom of page