Skip to main content

Maya Script Thingy

I like blogs. Today I made this script in Python that takes a bunch of things (for me specifically, it was control curves for a rig I'm making), and groups them, transferring their transformations (heh) on to the group, thereby zeroing out the transformations on the curves themselves. This is especially handy when you're positioning your curves in relation to your character, and you want to zero out their rotations while keeping the local rotation axis. You can't just use Freeze Transformation because it resets the object space rotation axis, which you kind of need to animate easily. It doesn't seem to work 100% perfectly, but it's good enough for me. 

Anyway, here it is for anyone to use

# Zeros out controls by grouping them, the group takes the transformations
import maya.cmds as cmds

selection = cmds.ls(sl=True)
rotation = []
trans = []
for object in selection:
    rotation = cmds.xform(object, q=True, ws=True, ro=True)
    trans = cmds.xform(object, q=True, ws=True, t=True)
 
    cmds.group( em=True, n = object + "ZeroGroup" )
    cmds.xform( object + "ZeroGroup", ws=True, t=trans)
    cmds.xform( object + "ZeroGroup", os=True, ro=rotation )
 
    parentObject = cmds.listRelatives( object, parent = True )[0] # first find the parent of the given object
 
    cmds.parent( object+"ZeroGroup", parentObject ) # parent the group to the parent of the given object
    cmds.parent( object, object+"ZeroGroup" ) # now parent object to the group


Enjoy!

(p.s. if there's anything wrong with it let me know!)

Comments

Popular posts from this blog

Prepare for CUBE

It's up to you to guide Cube around the things Cube can't go through. CUBE

Cr-48, A love story

Last December, Google sent me their CR-48 netbook to test out and help improve. Well I can proudly say that I stuck with their Chrome operating system for 6 solid months, but the more I used it the more I realized it's limitations. Their "nothing but net" philosophy that inspires this computer just wasn't for me, I had to have application support and a decent file manager. I had to have... Windows! It was a long complicated road, installing Windows 7 on this thing, but now that it is I've never been happier with this laptop. What I don't understand is why Google gave this laptop such nice hardware but gimped the operating system. You can still do a lot with just a 16 gigabyte hardrive. But who am I to doubt Google's infinite wisdom?

A Sign of Things to Come (!?!?)

I've been a little inactive here lately and for that I apologize, but I hope this can make up for it! My first ever youtube video and hopefully the first of many. Someday I want to look back on this and say "Wow! That looks awful!"