View Full Version : skin weights transfer tool

10 October 2005, 05:28 AM

i wrote this tool which is working pretty well for me.
It actaully exports skin weights into a text file n imports it back to the character according to vertex Number as opposed to maya which actually imports weigths according the proximity of the vertices.

I agree maya's way of doing it has its uses especailly across diff. chars but sometimes u want it to b precise this works in those cases!!

I spent a lot of time on this.
hope u guys think its good!!

absolutely open for critics.
n by the way it takes a long time while importing weigths as it goes thro evry single vertex n changes the weight values(exporting is REALLY quick tho)...if someone cud help me make it work faster that will be gr8. so pls dont close maya thinking it has hung...patience pls... :-)

thanks in advance for ur time!! rename the file to .mel if u wish

Robert Bateman
10 October 2005, 12:05 PM
if you look in the maya API devkit, there are two small examples that may be interesting, exportSkinClusterDataCmd.cpp and exportJointClusterDataCmd.cpp (for rigid skinning).

There is a bit of a known problem importing skin weights via the skinCluster and skinPercent commands. It's fairly simple to speed things up though, ou just need to ignore those commands and use setAttr on the actual weights array of the skin cluster directly! (the problem is that each call to skinPercent is generating undo information, which is where the overhead is being generated).

instead of using the skinPercent, do something along the lines of :

setAttr ($skinCluserName + ".wl["+$vertexIndex+"].w["+ $jointIndex +"]") $weightValue;

which should help speed things up a fair amount.....

Robert Bateman
10 October 2005, 12:10 PM
p.s. ou might find using a file dialog slightly easier -
fileBrowser is one of those undocumented mel commands that are very useful...
proc int
polyWeightImport( string $filename , string $type )
$fileId = `fopen $filename "r"`;
// do file stuff here....
fclose $fileId;
return 1;

// Using file browser to get file input
fileBrowser ( "polyWeightImport" , "Import" , "Best Guess" , 0 );

10 October 2005, 12:21 PM
that was a very useful tip...thanks a ton!! sure will implement them soon :-)

10 October 2005, 12:32 PM
setAttr ($skinCluserName + ".wl["+$vertexIndex+"].w["+ $jointIndex +"]") $weightValue;

very nice tip, I wrote a tool similar to that sometime ago, to transfert skinWeight between geometry with bifferent bones and skincluster ex: two feet.
It was kind of slow..will try with that command.

really cool


CGTalk Moderation
10 October 2005, 12:32 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.