Tuesday, August 25, 2015

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)


No comments:

Post a Comment