Wednesday, October 30, 2013

Cluster Edgeloops [Maya Python]

A Maya Python script that adds a cluster to each edge loop based off a single edge ring selection.

Saturday, October 5, 2013

V-Ray Dirt Multi Tile Baker [Maya Python]

This is a tool I wrote that will bake out V-Ray Dirt based off a min and max UV Region set by the user. I have used this in production on assets with a hundred tiles and baking out at 4 K resolution.

I will be releasing this in the near future on Creative Crash.

V-Ray Dirt Param Documentation
V-Ray Dirt Examples

Video Demo:

Input Mesh:


Wednesday, October 2, 2013

Joint Labeling Function [Maya Python]

This is a Python function that I have created to help me do joint labeling in Maya.

Oct 6th, 2013 - Add help docs. To access this type, 'acJntLabel.__doc__' or 'help(acJntLabel)'
Oct 8th, 2013 - Add functionality for user to pass joints through a selection or a list.

Video Demo:

Source Code:

 Author: Andrew Kin Fun Chan  
 Date: Sept 2013  
 Version: 1.0  
 Compatibility: Maya 2011+ (It will probably work in older versions as well. Contact me if you have issues.)  
 import maya.cmds as mc  
 def toList(objects):  
   This function takes in data and returns it as a list.  
   if isinstance(objects, str):  
     return [objects]  
   elif isinstance(objects, tuple):  
     return list(objects)  
   return objects  
 #acceptable side keys to use.  
 sideDict = {  
 #acceptable type keys to use.  
 typeDict = {  
       'Index Finger':19,  
       'Middle Finger':20,  
       'Ring Finger':21,  
       'Pinky Finger':22,  
       'Extra Finger':23,  
       'Big Toe':24,  
       'Index Toe':25,  
       'Middle Toe':26,  
       'Ring Toe':27,  
       'Pinky Toe':28,  
       'Extra Toe':29  
 acJntLabel ('Left', 'Other',None, 'oi')  
 def acJntLabel (side, type, joints = None, *args):  
   [Description:] This is a function that joint labels using the user input or selected joints.  
     If the selected joint names were...  
       lf_joint1_bnd, lf_joint2_bnd, lf_joint3_bnd  
     I would want to assign the side to Left, type to Other,   
     and remove 'lf_' & '_bnd' from the joint label name.   
     acJntLabel ('Left', 'Other', None, 'lf_','_bnd')  
   @param side: Name of joint label side.  
   @type side: *str*  
     Acceptable side parameters:  
       'Center', 'Left', 'Right', 'None'  
   @param type: Name of joint label type.  
   @type side: *str*  
     Acceptable type parameters:  
       'None', 'Root', 'Hip', 'Knee', 'Foot', 'Toe', 'Spine', 'Neck', 'Head', 'Collar', 'Shoulder',   
       'Elbow', 'Hand', 'Finger', 'Thumb', 'PropA', 'PropB', 'PropC', 'Other', 'Index Finger', 'Middle Finger',  
       'Ring Finger', 'Pinky Finger', 'Extra Finger', 'Big Toe', 'Index Toe', 'Middle Toe', 'Ring Toe',  
       'Pinky Toe', 'Extra Toe'  
   @param joints: List of joint names to label. If param is set to None, then get joints based off user selection.  
   @type side: *str*, *tuple*, *list*   
   @param *args: Name of strings you would like to remove from the joint name.  
   @type *args: *str*  
   joints = toList(joints)  
   if not joints:  
      joints = (sl = True)  
      if not joints:  
        raise RuntimeError('Must select or pass in joints.')  
   if side not in sideDict.keys():  
     raise RuntimeError('Side name,%s, must be one of the following: %s' % (side, sideDict.keys()))    
   if type not in typeDict.keys():  
     raise RuntimeError('Type name, %s, must be one of the following: %s' % (type, typeDict.keys()))  
   for jnt in joints:  
     print jnt  
     if not mc.objExists(jnt):  
       print '%s joint does not exist... Continuing to next joint.' % (jnt)  
     #assigning the side and type to all selected joints.  
     mc.setAttr ((jnt + '.side'), sideDict[side])  
     mc.setAttr ((jnt + '.type'), typeDict[type])  
     jntNewName = jnt  
     #looping through the args to remove them from the name.  
     for i, arg in enumerate(args):  
       jntNewName = jntNewName.replace(arg, '')  
     #assign the name of the joint label with the new name.  
     mc.setAttr ((jnt+'.otherType'), jntNewName, type ='string' )