Tuesday, August 25, 2015

Some useful shelf tools...

SNAP TO PLACE

How to use:

Copy the code below to the script editor and drag it onto your custom shelves so you can access it at any time (remember to save your shelves before quitting Maya)

Select object with correct location first and then the object you want to move to match the first. Then run the script found below. It snaps the second object(s) selected to the location and rotation of the first object's pivot.
If the second object(s) has any keyframes on any translation or rotation channels, it sets a keyframe at the current frame on those channels.
The rotations may not match if either one of the objects has freeze transforms.



CREATE CONTROL

How to use:

Copy the code below to the script editor and drag it onto your custom shelves so you can access it at any time (remember to save your shelves before quitting Maya)

This is a tool to create nurb curves as controls for a rig. When rigging I found myself going through the same steps a bunch of times to create all the controls I needed, so I created this shelf button that does about 90% of the job for me. Here's how it works:

Select the object and then run the script. It will create a nurbs circle and snap it to the object. It will  rotate the circle so that it's perpendicular to the longest dimension of the object and will resize it to make it slightly bigger than the second longest dimension of the object. It will also delete history on the circle and freeze transforms. This usually gets me pretty close to where I want to get and all that's left is moving or tweaking the shape in component mode to get it to look the way I want.


CREATE CAMERA

How to use:

Copy the code below to the script editor and drag it onto your custom shelves so you can access it at any time (remember to save your shelves before quitting Maya)

This tool speeds up the process of creating a camera and opening it in a new window. First find the camera angle you want using your perspective camera (or any other camera you don't mind moving around). With that viewport selected, run the script. It will create a new camera with the same properties and open a new panel to display the new camera view, with a resolution gate on, no grid and objects displayed in smooth shaded mode. It will also name the cameras incrementally as cam01, cam02, and so on.


LOCATOR AT SELECTION

How to use:

Copy the code below to the script editor and drag it onto your custom shelves so you can access it at any time (remember to save your shelves before quitting Maya)

Select an object and run the script. It will create a locator named 'objectName_loc' at the position of the pivot point of the selected object.

Dynamic parenting & space matching

USES:

This tool is useful when an object needs to have multiple parents and needs to switch which parent to follow within a scene. The space matching section prevents the object from popping to a different location when the parent is changed and makes sure that the object stays in place.
The top part of the window is used to parent the object to up to 3 drivers. It adds a "Follow" channel to the object, where the user can select the desired driver from a drop down list.
When assigning an object in the Space Matching section, it will load the list of parents from the "follow" channel. Switching parents with the buttons that load in this section will match the world space position of the object so that it remains in place, while switching parents by selecting from the list in the "Follow" channel of the object won't match the space and the object will pop to a different position.
The Space Matching section will work as well with dynamic parents that weren't created with the top part of this tool. For that case, there's a text input field to input the name of the channel that controls the parents.

INTERFACE:

Dynamic Parenting:

First select the object or objects to be parented and click on the "Object(s)" button. Then select what will be the world space (I usually assign the Master Control of the rig as World) and click on "World". Then select what will be the parent and click "Driver1". Driver2 is optional, you can assign a 2nd driver or leave it empty. Finally, click on "PARENT OBJECTS"
The script will parent the object under a locator (named objectName_loc) so that the translation and rotation channels of the object don't get locked by the parent constraint.

Space Matching:

If you created the dynamic parent using this tool, you can leave the default value ("follow") as the channel name. Else, type in the name of the channel that your object uses to select the parent (long name, not nice name*) and click on the "assign" button next to the text input field. Then, select the object with the dynamic parent and click on the top "assign" button. This will load one button for each parent. Clicking on the desired parent button will change the value on the object channel while keeping the object in the exact same place.

*The nice name is what Maya displays in the channel box, you will need to find out the long name of the attribute, which may or may not be the same. To find the long name, select the object and go to Modify/Edit attribute... Select the attribute from the list and look at the line that says New name, that will be the name you need to type in (case sensitive)

INSTALLATION:

To get the this tool download the script file and save it in your maya/version/scripts folder:

Then run the following code in the script editor (make sure to be in a python tab):
import spaceMatch
reload(spaceMatch)

You can save these lines in a shelf button for easy access.


If you don't want to download the file you can just copy the code below to the script editor and drag it onto your custom shelves so you can access it at any time (remember to save your shelves before quitting Maya)