Robust tools for skin weight export/import

83 views
Skip to first unread message

AK Eric

unread,
Jun 20, 2019, 6:34:29 PM6/20/19
to Python Programming for Autodesk Maya
I've recently changed companies and starting something from scratch.  One of the tools I need (and we had before) is a bulletproof solution for skin weight export/import.  I'm a bit out of touch with what's out there in the community since I've not had to look into this for years.  Maya's built-in solutions are sorely lacking when used on any sort of complex asset.  

Are there any off-the-shelf tools available ($ is fine) that people would recommend?

I've been looking at ngSkinTools, but it's export\import step seems pretty clunky as well.  As in, you can't import weights unless the mesh is already skinned, which sort of defeats the purpose.  I could introspect the json weight files and pre-skin the assets based on my own wrapper code, but... if I paid for it why should I have to do it?  I figured someone by now has solved this problem and is trying to profit from it.

Any other suggestions?  Much appreciated.

Andres Weber

unread,
Jun 21, 2019, 3:53:06 PM6/21/19
to Python Programming for Autodesk Maya
Funny enough I actually have written those helper scripts since it was pretty simple as their JSON files are quite well formatted.  Honestly I never really looked further than ngSkinTools as they're the most complete and functional skinning toolset I've come across and used for many years.  Apologies as this is quite old code and not very well structured:

import json
import maya.cmds as mc

def copy_bind_from_ng_file(file):
    """ Copies skinCluster from ngSkinTools JSON file to make the same skinCluster before importing weights.
    Args:
        file (str): file...
    Returns [str]: list of influences that we used to build the skinCluster
    Usage:
        copy_bind_from_ng_file('path_to_your_ng_skin_tools_weights_file.json')
    """
    influences = []
    missing_influences = []

    with open(file) as f:
        data = f.read()
        json_data = json.loads(data)
        f.close()

    for value in json_data['influences']:
        influence = json_data['influences'][value]['path'].split('|')[-1]
        if mc.objExists(influence):
            influences.append(influence)
        else:
            missing_influences.append(influence)
    
    if missing_influences:
        print 'Missing Influences from your file: \n{}'.format(missing_influences)

    result = cmds.confirmDialog(b=['OK','CANCEL'], m='You have %d missing influences...continue adding skin cluster from file with %d influences?' % (len(missing_influences), len(influences)))

    if result == 'OK':
        mc.skinCluster(influences, mc.ls(sl=True)[0], tsb=True)

    return influences

AK Eric

unread,
Jun 21, 2019, 6:25:50 PM6/21/19
to Python Programming for Autodesk Maya
Thanks for that Andrew!  The ngSkinTools dev got back with me as well with a similar solution, although it still crashes, sigh.  

I'm going to continue to investigate the ngSkinTools API, but am still open to other solutions as well.

HarshadB

unread,
Jun 23, 2019, 11:20:27 PM6/23/19
to Python Programming for Autodesk Maya
I feel ngSkinTools is more of a painting weights toolset plugin than a full-fledged tool to handle import/export skin-weights at a production level. It's more of a user tool than a pipeline tool. Yes, it would be very convenient to have a function to select the joints in the exported file, that is true, but it still does a decent job the way it is by design. The next major version in future would be awesome I presume.

You can look at mGear Rigging Framework. It does have pretty stable skin-weights import/export tools built in.

-H

AK Eric

unread,
Jun 24, 2019, 6:14:15 PM6/24/19
to Python Programming for Autodesk Maya
Thanks Harshad, I'll give it a look!

AK Eric

unread,
Jun 24, 2019, 7:11:49 PM6/24/19
to Python Programming for Autodesk Maya
I got mGear in and working, thanks @HarshadB : I found the api docs online, and the source, but is there any sort of overview on how the skinning import\export works?
By default (at least via the ui), it seems to only import if the vert count matches, which is pretty limiting.  Appreciate the info though.

HarshadB

unread,
Jun 24, 2019, 11:29:03 PM6/24/19
to Python Programming for Autodesk Maya
Yes, unfortunately it's limited to vertex count. mGear's skinIO is based on Chad Vernon's skinIO (for which he has a tutorial on CGCircuit): github

Maya has its own deformer weights import export tools that are very stable (Under deform menu). As long as you have geometry which is not drastically different from the source, they will transfer weights to non-similar geometry by changing the mapping method under import. You can write your own tools around it if you can. Or find someone who already has.
To clarify more, importing to different geometry by above command works using Barycentric coordinates. As do the default maya copy, mirror functions (The reason they are dependable and stable).

Hope the info helps in your search.

-H

AK Eric

unread,
Jun 27, 2019, 8:32:03 PM6/27/19
to Python Programming for Autodesk Maya
Thanks for the info:  I've used deformerWeights successfully, but (like you mentioned) it still requires a large amount of wrapper code to make it functional in a real pipeline.  Which I'll probably end up writing myself if I can't find anything off the shelf ;)
Reply all
Reply to author
Forward
0 new messages