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

Color x Color progress

It's the Hunter x Hunter manga but with color added.


Here's my first one, Ch. 351 pg. 12
Original http://imgur.com/a/Sslpu

Second, Ch.351 pg. 18


Third, pg. 09


Fourth, pg. 07


I'll probably make more?
link originals again Original http://imgur.com/a/Sslpu

I even made a video with sweet music


Progress!

So I followed a tutorial from Digital Tutors and ended up with this


Not the greatest thing ever, but I'm relatively proud of it.


Oh here's some old stuff I did a few months ago


Quick and dirty update

Lighting is hard. That laser glow is just way too intense but it's kinda nice in it's own way and I still need to work on making the light more evenly distributed. I'm thinking about decompiling whatever map this scene is from to see how Valve set up their lights. The environment is nowhere near finished, but fret not, the final scene will be done within the week.