Saturday, June 25, 2011

Weight Painting - Maya 2011

I was using Maya 2011 and could not get used to the new weight painting system. To weight paint like how we used to in the previous Maya (2009 and before), just go into the Paint Skin Weights Tool options, change the "Normalize Weights" from "Post" (default) to "Interactive". A message box will pop up and ask if you want to normalize the weights, in which I prefer to pick 'No'. Normalize Weights is accessible from "Edit Smooth Skins option" if I need it later.

Friday, February 4, 2011

joint Zero-ing

Here's a simple Python script that is used to zero-out selected joints' or given joint's rotation value and joint orient value. 

For the first argument, 'jointName' is used to specify a given joint name. If you intend to run the script for selected joints instead, give a 'None' or do not use this argument at all. It is defaulted as 'None' though. Second and third argument is 'rot' and 'jo'. Give it a 1 to 'rot' to zero-out rotation values or a 1 to 'jo' to zero-out joint orient values. Otherwise, give them a 0 to do nothing on that particular arguments.

1) This will zero-out rotation values for joint1, but its joint orient will not be affected:
jointZero (jointName='joint1', rot=1, jo=0)

2) This will zero-out rotation values and joint orient values for all selected joints:

jointZero (rot=1,jo=1)

FULL SCRIPTS (to run before hand):

def jointZero (jointName=None, rot=1, jo=1):

    if jointName == None:
        sel =
        for joint in sel:
            if rot == 1:
                cmds.setAttr ('%s.rx'%joint, 0)
                cmds.setAttr ('%s.ry'%joint, 0)
                cmds.setAttr ('%s.rz'%joint, 0)    
            if jo == 1:
                cmds.setAttr ('%s.jointOrientX'%joint, 0)
                cmds.setAttr ('%s.jointOrientY'%joint, 0)
                cmds.setAttr ('%s.jointOrientZ'%joint, 0)                    
        if rot == 1:
            cmds.setAttr ('%s.rx'%jointName, 0)
            cmds.setAttr ('%s.ry'%jointName, 0)
            cmds.setAttr ('%s.rz'%jointName, 0)    
        if jo == 1:
            cmds.setAttr ('%s.jointOrientX'%jointName, 0)
            cmds.setAttr ('%s.jointOrientY'%jointName, 0)
            cmds.setAttr ('%s.jointOrientZ'%jointName, 0) 

Note that this is a very simple script. Fail-proof procedures are not added. So make sure your selection type is 'joint' and no rotation or joint orient attributes are locked or non-keyable. 

That is all for now. Hope this sheds some lights to the blog's viewers.

Tuesday, January 11, 2011

Animation Transfer Script

A friend of mine was asking me if it is possible to have a script that can save the animation data into a text file and load the saved animation data text file into another object. So I wrote a simple Python script that could perform such operation. It saves the keys as well as its animation curves and tangents.

The GUI is pretty simple to navigate. There are two tabs, LOAD and SAVE. To save out animation data into a text file, first select the object with the animation that you like to save out. Then click 'Browse' to browse to a directory where you want to save the text file containing the animation data. You can specify the start frame and end frame, as well as choosing the channels you like to save such as translate, rotate, scale and visibility. I made an additional custom attribute if you ever need one. The 'Save Data' button executes the saving data script. And to load the animation data, all you need to do is to choose your object, click 'Browse' to select your saved animation data text file, and decide whether if you like to remove the current keys on the selected object by ticking the checkbox. A click on 'Load Data' will executes the loading data script.

That is all.

Download link: Python File :

** Note that this script is very simple. It can only save 1 object's animation at one time. Not that great, I know! Well, if you have any suggestions to make it more useful, let me know. Thanks!

Tuesday, January 4, 2011

Joint Labeling

I developed this script about a year ago. It is used to rename the joint labeling and set the 'side' of the selected joints according to their prefix. In my case, I used 'cc' for center, 'll' for left side and 'rr' for right side. You may modify that to suit your preference. It is important to make sure the name on both sides of the selected joints are the same except its prefix. The script is as below:

# Import Maya functions

import maya.cmds as cmds

# Prefixes change here

leftSide = 'll'
rightSide = 'rr'
center = 'cc'

def jointLabeling ():

    sel = []
    sel = (sl=True, fl=True)

    for i in sel:

        afterName=i.split ('_', 1)[0] # take the starting prefix and check
        afterNameTwo=i.split ('_', 1)[1] # take the obj's name and check

        if afterName ==
            cmds.setAttr ('%s.side'%i, 1)
            cmds.setAttr ('%s.type'%i, 18)
            cmds.setAttr ('%s.otherType'%i, '%s'%afterNameTwo, type= "string")
            print 'Labeled %s prefix called %s' %(afterName, afterNameTwo)

        if afterName == rightSide:
            cmds.setAttr ('%s.side'%i, 2)
            cmds.setAttr ('%s.type'%i, 18)
            cmds.setAttr ('%s.otherType'%i, '%s'%afterNameTwo, type= "string")
            print 'Labeled %s prefix called %s' %(afterName, afterNameTwo)

        if afterName == center:
            cmds.setAttr ('%s.side'%i, 0)
            cmds.setAttr ('%s.type'%i, 18)
            cmds.setAttr ('%s.otherType'%i, '%s'%afterNameTwo, type= "string")
            print 'Labeled %s prefix called %s' %(afterName, afterNameTwo)