Combining multiple rigs

Combining multiple rigs

Anonymous
Not applicable
764 Views
3 Replies
Message 1 of 4

Combining multiple rigs

Anonymous
Not applicable

Hey, 

 

I need a little help if possible, 

 

Currently have 4 pieces to my model (head, arms, torso, legs)

 

Trying to combine them all together onto one rig and then copy the weights over


A lot of the joints in one rig are in another, so there's multiple occurrences of each.

 

I've tried to make it as simple as possible but it's quite complex, I'm not absolutely terrible at scripting but can't figure this one out so thought I'd turn here for help.

 

I need to make a script as I'd like to be able to do these characters in batches and make it as quick as possible. Combining the rigs together was the easy part. Just having trouble with the weights

 

They all get copied over but a couple of them end up really screwed.

 

Any help is highly appreciated 🙂

 

Thank you

 

Here's the script: 

 

    #Lock all weights so new joints being added to skinClusters don't effect current weights
    for joint in cmds.ls(type="joint"):
        if cmds.objExists(joint+".lockInfluenceWeights"):
            cmds.setAttr(joint+".lockInfluenceWeights", 1)

    #Move new joints to skinClusters
    for joint in cmds.ls(type="joint"):
            for skinCluster in cmds.ls(type="skinCluster"):
                if("COMBINED" not in joint and joint in cmds.skinCluster(skinCluster, query=True, influence=True)):
                    if("|" in joint):
                        cmds.skinCluster(skinCluster, edit=True, addInfluence="COMBINED:"+joint.split("|")[-1])
                    else:
                        cmds.skinCluster(skinCluster, edit=True, addInfluence="COMBINED:"+joint)

    #Unlock all weights
    for joint in cmds.ls(type="joint"):
        if cmds.objExists(joint+".lockInfluenceWeights"):
            cmds.setAttr(joint+".lockInfluenceWeights", 0)

    #Transfer weights from old rigs to new rig
    for joint in cmds.ls(type="joint"):
        for skinCluster in cmds.ls(type="skinCluster"):
            if("COMBINED" not in joint and joint in cmds.skinCluster(skinCluster, query=True, influence=True)):
                if("|" in joint):
                    cmds.skinCluster(skinCluster, edit=True, selectInfluenceVerts=joint)
                    cmds.skinPercent(skinCluster, transformMoveWeights=[joint, "COMBINED:"+joint.split("|")[-1]])
                    cmds.select(deselect=True)
                else:
                    cmds.skinCluster(skinCluster, edit=True, selectInfluenceVerts=joint)
                    cmds.skinPercent(skinCluster, transformMoveWeights=[joint, "COMBINED:"+joint])
                    cmds.select(deselect=True)

 

0 Likes
765 Views
3 Replies
Replies (3)
Message 2 of 4

mcw0
Advisor
Advisor

Firstly, to add new joints as influences, you don't have to lock all the other joints first.  You can just add the new joints with the lockWeights flag set to on.

 

As for transferring weights, you say "They all get copied over but a couple of them end up really screwed.".  I personally don't use the "transformMoveWeights" option much as I find it slow.  You can lock all influences except the 2 in question.  Then you can query the weight of the first influence and apply that as the weight for the second influence.  This should not result in any "screw ups".  🙂 

0 Likes
Message 3 of 4

Anonymous
Not applicable

That sounds exactly like what I was looking for, and I didn't see that flag. Thanks!

 

You say "Then you can query the weight of the first influence and apply that as the weight for the second influence."

 

Do you have an example snippet of this? Not sure which command you're talking about

 

Also, thanks for the response.. appreciate it 🙂

0 Likes
Message 4 of 4

mcw0
Advisor
Advisor

float $weight = `skinPercent -t $influence1 -q -v $skinCluster1 $pt1`;    //  This will query the weight of $influence1 on $pt1

 

To apply the weight:

 

skinPercent -tv $influence2 $weight $skinCluster2 $pt2;

0 Likes