Jul 27

Been awhile since I wrote anything Maya related so I thought I’d do a brain dump.

So right now I’m working in Maya at work for a short time. Get to work on a previz rig that has to be built from the ground up with a build system. Now I’ve written build systems and worked with them in the past but have not run into this process. The processes I’ve used in the past, the bound mesh was imported in and constrained to the animation rig. Well with this system, it will be importing a clean mesh and the joints and binding the mesh programatically. Actually this remined me that the rig is being built before building the weights. I need to flip this process.

I had to think how I wanted the scripts to create this weighting process and started looking into other scripts out there that exported/imported weight info. All the scripts I’ve come across have there own format for exporting and reading in the data. Well, I guess the easy way would to export the data with one of the scripts and use the import function in the script to rebuild back into the next maya session in the build system. However I want this to be fairly generic and be self-contained.

Now I wish I can devuldge the script but since I wrote it at work I can’t but I’ll describe the process of what I’ve done so far. So the script process each mesh selected and creates a function in an external file like “global proc weight_nameOfMesh()”. With in that function, it grabs all the joints used and the geo and binds it. Renames the skinCluster and has a bunch of skinPercent calls.  One thing I had to make sure when creating this that the weights are normalised so they equal up to 1.0 before exporting the data.  Great, so at this point the function binds the geo and rebuilds the weights however normalization is becoming an enemy. When setting the weights in a linear fashion, the verts are wanting to be normalised and there are times when the wieght doesn’t take with the skinPercent. So what needs to be done is all the weights need to on hold and set all the weights to zero then start rebuilding from the ground up. Hmm, scratch head. I guess what needs to happen is when I export the data and it builds each function and at the end of file I need to create another function that will get called in each funtion that calls this zero weights then unhold the wieghts. So at the end of this export function I have a file that contains many funtions that can be called from another function to rebuild the weights from the ground up. Basically a script that builds a script.

Example format:

global proc weights_l_foot(){

select joint1,joint2….;

select -add l_foot;

skinCluster -tsb -mi 1 -name l_foot_skinCls;


skinPercent -tv joint1 -v 1 l_foot_skinCls l_foot.vtx[1];




global proc zeroOutWeights(){



global proc unholdWeights(){



3 Responses

  1. Lucas Martell Says:

    I love brain dumps, its always good to see other people’s workflows. So is this external file reused once its generated, or does it regenerate each time the rig is built? Or since its previs, maybe the rig is built once and the bound geometry is saved with the rig? Thanks for the ideas!

  2. Nicolas Says:

    Hi Sean…

    I’ve had to modify such a script from Highend recently, to accomodate to our needs, and came to the same normalize problem when importing back the weights. I used a trick that is to turn normalization off before importing the weights, set all vertices weights to 0 (via a prune command for example), proceed to the import, and turn normalization back on… Here we set the weights bone by bone, so it’s fairly easy to use this method. But perhaps you use another method, as I see you use skinPercent for each vertex/joint, which can become VERY slow if you have a lot of points…


  3. admin Says:

    This external file is as self contained script that rebuilds the binding. So in this script file there will be at least 3 funtions. One that binds the geo, second one sets all the weights to zero (called in the first function) and the last to unhold all the weights(called at the end of the first one).

    Well, I thought it would be slow at first but I just ran my full script on 52 pieces of geometry which included a nurbs surface(yuck) with a total of over 25k of verts. To export the data took around 20 sec. To run the external script took under 30 sec .

    Now if I had the time I’d try to figure out a way to lump all verts with the same weight to a paticular joint so it’s less skinPercent calls. Small savings I’m sure. I have to add that I’m on a 64bit machine so I haven’t tried this on a 32bit. But overall it’s pretty slick.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.