Sunday, October 12, 2014

Snap Keys Tool UI


USES
The Maya SnapKey command can't resolve cases where there is more than one keyframe in between two consecutive whole number frames and you'll get a warning message like this: "// Warning: line 0: Had to skip snapping on some keys since multiple keys existed between the snap multiple. Command result indicates number of skipped keys. // " 
The Snap Tools UI provides tools to handle this situation,

INTERFACE

One button fix:
The Snap and Fix button will call the Maya snapKey command on the selected time range and then handle the leftover non-integer keyframes following these rules:
- if the previous whole number frame doesn't have keyframes, it moves the non-integer key to the previous whole number frame.
- if the previous whole number frame already has a keyframe, it moves the non-integer key to the next whole number frame, unless the next whole number already has a keyframe
- if both the previous whole frame and the next whole frame already have keyframes, it deletes the non-integer keyframe.

Manual fix:
If you want a different solution than the automatic "Snap and Fix" you can handle it manually using the following tools that work on the selected time range.
Update list: It populates and refreshes the "Select key:" drop down menu with all the non-integer keys found in the time range for the selected object. You will need to use this button to refresh the list if you alter the keys without using the Snap Tools UI (for example using Ctrl+Z or deleting or moving a key directly from the timeline or the graph editor)
Snap: It calls the Maya snapKey command and populates the  "Select key:" drop down menu with all the non-integer keys found in the time range for the selected object.
The rest of the tools are pretty self explanatory:
Delete selected key
Move key to previous whole number
Move key to next whole number
Go to selected key

INSTALLATION

To get the Snap Tools UI, download the script file and save it in your maya/version/scripts folder:
Download snapTools.py

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

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)



Wednesday, September 10, 2014

Marker Keys UI



The Marker Keys tool looks up on what frames in the timeline (or a selected time range) the original object has keyframes and sets "marker" keyframes (just for reference) on the recipient object.

USES
Sometimes after my blocking animation pass is done, a new ctrl is added to the rig (e.g. clothes ctrls, accessory ctrl) or a new prop is added to the scene. The new ctrl doesn't have any keys on the timeline, so I use marker keys as a reference to know where my blocking poses are, and that way my new ctrl will have keyframes on the same times as the rest of my ctrls. I also use marker keys when part of my blocking is not working (like an arm for example) and I want to delete all keyframes on those ctrls and start from scratch.

INTERFACE
Selection section
This section is used to determine the objects and time range that will be used by the "SET MARKER KEYS" function. First you need to select an original object (the one that already has keyframes) and press "assign original" and then select the recipient object (the one that will get the marker keys) and press "assign recipient". If you select multiple objects, only the first one will be assigned.
Then you can select a time range, or by default the UI will load  the values you have your timeline set to.

Keyable channels section
You can select which attributes get keyed. By default, only Tx is selected, since you only need to have one channel keyed to get a red "tick" on your timeline and be able to use the "," and "." buttons to navigate between keyframes. Selecting no channels at all will result in all attributes being keyed, including scale, visibility and any other attributes your object may have.

Finally, press "SET MARKER KEYS" and the keyframes will be assigned to your recipient.

Additional tools section
The lower section consists of additional tools that can be useful when working with this method. These tools work on the current selection, no matter what's assigned as Original or Recipient at the top.

Copy to next key:
Copies the key at the current time and pastes it where the next marker key is.
Once the marker keys are set, I'll go to each one and position the ctrl where I want it at that point in time. When I go to the next marker key, the ctrl will go back to the initial position (where it was when I set the marker keys), in most cases, this is not what I want, I want to keep animating from the position in the previous pose. For that purpose, before moving to the next marker key, I use the "copy to next key" tool.

Delete all keys:
Deletes all keyframes in the time range determined in the Selection section.

Set keyframes per channel:
Sets a keyframe only on the channel clicked. This is the same as right clicking on a channel in the channel box and selecting "Key Selected", but you only need to click one button.


INSTALLATION
To get the Marker keys UI, download the script file and save it in your maya/version/scripts folder:
Download markerKeys.py

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

import markerKeys
reload(markerKeys)

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)