scSaveWeights for export/importing skinCluster weights in Maya


I have written an useful Maya python API plugin which exports out weights from polygon mesh or vertices to text file(optionally binary),Which can be used later.
This process is mostly useful when User wish to change position of joints in a rig with skinCluster , or just want to update rig file with latest weights from other file.
I have in past used Michael comets famous Mel script cometSaveWeights, which works great but is very slow when importing weights on dense mesh.

It was my first attempt at writing something in Maya API. Attached in plugin which I have tested on Maya 2008 to 2011.

Mel Command to export weights
scSaveWeights -roundOff 5 -action “export” -file “d:/weights.txt”;

Mel Command to import weights
scSaveWeights -action “import” -file “d:/weights.txt;

Download
scSaveWeights.zip

Go to windows>Settings/prefrence > plug-in manager and browse to the scSaveWeights.py
I would suggest to open the py file in IDE and read through comments in the beginning of  script.

Exporting weights on polygon mesh with vertex count 12432 skinned with 255 joints took 7.6378 seconds
whereas Importing took 66.3445147672 seconds and in quick mode it takes 19.937 seconds while exporting
and takes 7.5559 seconds while importing.

Importing weights with cometSaveWeights.mel took more than 7 minutes on same Mesh. 

edit: updated script to work with selected polygon object and in component mode, while importing weights.

Advertisements

16 thoughts on “scSaveWeights for export/importing skinCluster weights in Maya

  1. Hi there, I’d like to thank you for your handy plugin; but I’d also like to ask you a few questions.

    Do you know how the list of vertices in the exported file relates to the list of vertices you’d get in an OBJ file? I’m trying to work your plugin into my mesh animation pipeline in my game project but I’ve run into a major issue:

    I can’t seem to find a relation between the vertices in the OBJ file and yours. Do you know why this might be? I would have assumed that everything exports from Maya in the same fashion. Do you know of a possible solution?

    Thanks.

    • Hi Derek, I am releasing one update to my plugin, as there are small issue while importing skin weights, (in current version only selection of vertices works)

      That said my plugin saves out skinweights as per vertex id, if your obj file has different mesh order, I’m afraid you will get uneven weights.

      I hope to update it near future, Thanks Sunny

  2. Hi, thanks for this plugin. I cannot use it and I don’t understand why. In the instruction it is mentioned a file that is not in the zip archive (scSaveWeightsWin.py). I cannot either export nor import anything as I receive this error: # Error: IOError: file G:/Documents/maya/2013-x64/plug-ins/scSaveWeights.py line 173:
    What should I select in order to properly export and import things? Sorry, I am a little clumcy with Maya and these things
    Thanks in advance 🙂

    • I have exported the file. For some reason that I don’t know now it works, but when I try to import I first select the file, then I click on Select joint from File and I see that they are selected in the outline, then I clickc Import skin Weights, but I receive an error message that says that too many objects were selected: // Error: line 1: Could not save file “G:/Documents/maya/projects/animschool/Class3 – Rigging/Asmt6/autosave/Glib_wk3_17_RebuiltOfTheJoints.0001.ma”.

  3. I dealed with the same issue on windows so you can try the quick mode flag.
    On linux i didnt get the problem (it works without the quick mode).
    But I dont understand what does it change so its risquy !!

  4. 1—-For those how face this problem:
    # Error: RuntimeError: file line 2: KeyError: file C:/Program Files/Autodesk/Maya2014/bin/plug-ins/scSaveWeights.py line 304: #

    the line 304 is in the function def __scNormalizeWeight().
    the line 304 is nonZeroDict[heavyJnt] = nonZeroDict[heavyJnt] + remWeight

    —-) This is an issue with the normalization so do a normalization before you use the scSaveWeight import-export functions.

    2—–Also dont forget that a file generated with quickMode is not readable in a non-quickMode…. and vice versa

  5. When I am exporting my skin weights I keep getting this error-
    # Error: RuntimeError: statusError: Please select Polygon object, or vertices to save weights
    and I have the geo selected. I just don’t know what I am doing wrong if anyone could help that would be great!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s