Demo of Python API usage in Maya
This plugin began as a learning exercise based on Dhruv Govil’s “Learn to Code with Python to Work Faster in Maya” tutorial and evolved into a streamlined tool for animators. In Maya’s Animation Editor, it can be tedious to craft smooth, stylized transitions between two keyframes—especially when creating character animations with an “anime” aesthetic that require repeated tweaking of in-between frames. To address this, I developed a keyframe tweening script using Python and Maya’s cmds library. Instead of relying on linear interpolation alone, the tool includes an Ease-In/Ease-Out toggle: when enabled, the slider’s percentage value is mapped through a smoothstep curve (3t² – 2t³), allowing animators to accelerate into or decelerate out of a keyframe without manually adjusting animation curves. Moreover, the script automatically applies the same tween operation to every selected object rather than a single control, making it easy to synchronize multiple controls or props without copying and pasting keyframes by hand.
The user interface is compact yet powerful: a floating window titled “Tween Ease Toolkit” contains a float slider (0–100%) for tween percentage, a checkbox labeled “Use Ease In/Out,” and a “Tween Selected” button. When the slider’s value changes or the button is pressed, the plugin queries each selected object’s keyable attributes, locates the surrounding keyframes around the current time, computes either a linear or eased interpolated value, and immediately sets a new keyframe at the current time. If no objects are selected or an attribute lacks valid surrounding keys, the script issues a Maya warning to guide the user. Because the entire implementation relies solely on Maya.cmds (no external dependencies), it runs out of the box in Maya 2022 and later. The code is organized into a module with clear function names, proper license headers, and error checking, and is hosted on GitHub to demonstrate a clean directory structure, version control, and documentation.
Installation is straightforward: place tweenEaseTool.py
in your Maya scripts directory or any folder in your PYTHONPATH, then import it in Maya’s Script Editor to automatically open the toolkit window. For quick access, you can also create a shelf button that executes import tweenEaseTool
. Under the hood, the function tween_multiple
orchestrates the core logic by querying keyframe times via cmds.keyframe
, retrieving attribute values with cmds.getAttr
, applying either a linear or smoothstep interpolation, and writing the new keyframe with cmds.setKeyframe
. The result is a compact, efficient tool that saves animators countless hours of manual in-between adjustments and tangent edits, while demonstrating proficiency in Maya’s Python API and user interface commands.