Maya – mGroup, zero out transformations

To zero out the transformations of an object without using the freezeTransforms method. This is a very common method which I have seen on many websites. Here is what I do:

Create a locator and move it away from the origin and rotate it some arbitrary amount. If you look in the channel box it will have values for the translations and rotations. Sometimes you want to zero this but keep the relative position. Now create an empty group. Its world space location will be at the origin. Select the locator and shift-select the group probably by way of the outliner or hyperGraph since it isn’t visible. point and orient-constrain the group to the locator. Now the group has the exact position and rotation as the locator. Delete the point and orient-constraints from the group, and parent the locator to the group. If you look in the channel box it will have all zero’s. Thats it fairly easy.

Here is some code I wrote that will automate the process:

global proc mGroup()
{
string $selected[] = `ls -sl`;
for($obj in $selected)
{
string $group = `group -em -name ($obj+”_grp”)`;
select -r $obj;
select -tgl $group;
delete `pointConstraint -offset 0 0 0 -weight 1`;
delete `orientConstraint -offset 0 0 0 -weight 1`;
string $objParent[] = `listRelatives -p $obj`;
if(size($objParent) != 0)
{
parent $group $objParent;
parent $obj $group;
}else { parent $obj $group; }
}
}

mGroup;

Syntax Highlighted picture:

mGroup

Advertisements

~ by animatix on February 13, 2008.

One Response to “Maya – mGroup, zero out transformations”

  1. Hello, I know this post is old, but I ran into it searching for something completely different and thought I’d pipe in my two cents. You can also do this with duplication. Duplicate the group you want to zero out and parent the original group to that. If you’re doing this by hand it can greatly reduce the time spent, and if you’re doing it by code it can simply things a bit.

    Here is an extremely simplified example. If you want a more robust function, take look at my Good Parenting script. //End Shameful Plug//

    global proc mGroup()
    {
    string $selected[] = `ls -sl -l`;
    for ($obj in $selected){
    parent $obj `duplicate -po -rr $obj`;
    }

    }

    mGroup;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: