Tuesday, April 26, 2011

Selection, Renaming, and Iteration.. Oh My!

Thought i would share some of the handy scripts i have made why making rigs for games. Some of these are short, but have saved me tons of time.

import pymel.core.general as pmg
import pymel.core.windows as pmw
import pymel.core.rendering as pmr
import pymel.core.modeling as pmm
import pymel.core.animation as pma
import pymel.core.system as pms
import maya.cmds as cmds
import maya.mel as mm

This one is handy, will rename some objects and make the last bone in the chain "Nub". This needs some adjustment to be able to handle number padding, but its a goood start.

def renameBones(boneName):
# need to add number padding as a function

numStart = 1
selection = pmg.ls(sl=True)
for obj in selection:
pmg.select(obj, hi=True, r=True)
nubTest = pmg.ls(sl=True)
# Check to see if node has children, if not name it 'Nub'
if len(nubTest) == 1:
replaceName = boneName +'Nub'
pmg.rename(str(obj) , replaceName)
replaceName = boneName + '0' + str(numStart)
pmg.rename(str(obj) , replaceName)
numStart += 1

I needed a quick way to select all the joints in a chain, and ignore all the other constraints and nonsense that can get added in there.

def sJoints():
origSelection = pmg.ls(sl=True)
joints = []
for obj in origSelection:
if pmg.nodeType(str(obj)) == 'joint':
pmg.select(joints, r=True)


I found that when creating custom rigs I had to iterate alot through attributes here is a pretty quick solution for doing common things through attributes. Basically making an array out of each and running through them.

for attr in ['t', 'r','s']:
for axis in ['x','y','z']:
pmg.setAttr(str(objName)+'.' + attr + axis , lock=True, keyable=False)

Monday, April 25, 2011


Was reading more of the Drawn to Life series and stumbled across yet another gem that I had the share:

"You must create. The injunction of life is to create or perish. Good physical and mental conditioning are necessary to do this. Remember this: The creative energy that created the universe, created you, and its creative power is in you now, motivating you, urging you on - always in the direction of creative expression. I have a formula: 'Impression minus expression equals depression.' This is especially aplicable to artists. We have trained ourselves to be impressed (aware) of all things around us, and in the natural course of our lives those impressions cry out to be expressed - on paper, on canvas, in music, in peotry, in an animated film.
So shape up!"
- Walt Stanchfield

There is so much truth in what he says, if i go too long without sketching, writing, rigging, or modeling something i can feel a blackness start to creep in my life and i start to lose any sort of purpose. All it takes is a couple of creative sessions though and i am back to a brighter life, things have a richer color, and i make connections that werent there before in all aspects of my work, and life. Never under estimate the power of sitting down and letting you imagination wander, in whatever media most speaks to you!

That being said write!! If you want to do something great you have to get your ideas out somehow! Moments of inspiration can come to you in a flash, and be gone just as quickly. Force yourself to be aware enough to recognize them, and you can start to put yourself in more situations that will inspire you but be sure to write it down, otherwise all is lost! There is no telling if you will have that unique thought again!

You can tell yourself that you will remember , and you might, but most likely you wont. The writing not only reminds you of the thought, but it also reminds you that you HAD one! How many great ideas have you had that you dont even remember to think about??! All that is left is a vague memory...