Hey All,

I'm working on a tool right now for exporting & importing skin weights. I'm 
still in very early stages of writing it, but have hit a snag I'm not quite 
figuring out on my own. Since this is a learning excercise for me, I could 
really just use someone more experience than I to please take a glance over.

Everything seems to work great If I run the two commands, getSkinWeightsData(), 
and setSkinWeightsData() back to back.  But If I run the first, then do some 
weight painting, then try to set it back to what the first function returned, I 
get really weird results. I'm not quite sure how to solve it.  I know these are 
really simple functions, and probably not the best way to do this, but this is 
where I'm at right now ;)

#=======================
import pymel.core as pm

def getSkinCluster( node=None ):
    if not node:
        node = pm.ls(sl=1)[0]            
    return node.listHistory(type="skinCluster")[0]  


def getSkinWeightsData( node=None ):
    skin = getSkinCluster( node )
    weightData = {}
    for vertID in skin.attr("weightList"):    
        for plug in vertID.attr("weights"):        
            weightData[ plug.shortName() ] = plug.get()                         
  
    return weightData


def getSkinDeformersList( node=None ):
    skin = getSkinCluster( node )
    return [ dfm.inputs() for dfm in skin.attr("matrix") ]



def setSkinWeightsData( weights, node=None  ):   
    skin = getSkinCluster( node )   
    for key in weightData:
        skin.setAttr( key, weights[key] )
    


weightData = getSkinWeightsData()  

setSkinWeightsData( weights=weightData )

#=======================

Thanks,
Kev

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/cdfc9a69-1178-4e9c-b441-17ffaa768520%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to