Autodesk Maya 2023
Python
PyQt
Maya's OpenMaya Python API 2.0
Plugin Development
This tool (Github)
is a recreation of a basic version of the Tween Machine tool as a Maya Command Plugin.
The plugin is written in Python using the Maya's OpenMaya API for Python and comes with an associated PyQt user-interface.
The tool creates a new key at the current time, between two existing keys and adjusts the value of the new key to be closer
to either the previous key or the next key based on the tween value.
The UI provides a slider to visualize results of different tween values.
The tools allows working either on animated DAG objects (in this case, key is added to all animation curves of the selected object)
or on selected animation curves.
The video below demonstrates the plugin tool and how it works in Maya.
Note: The red tick mark representing a new key in the time slider did not show up on screencapture. But you can see that a new key is
added in the animation curve example.
To create a command plugin, the plugin extends the MPxCommand class available
in the OpenMaya API :
Maya Python API 2.0 Reference
This command is undoable, so it allows undo on the add key operation.
The command plugin follows the follownd steps:
The UI is developed with PyQt.
The UI script ensures that the tween machine plugin is loaded before displaying the UI. It loads the plugin
if it's not already loaded or throws an error if it is unable to load the plugin.
The UI elements are simple: a slider for selecting the tween value, a text label for the slider and another label to display
the current slider value.
The tween machine command is called when the slider value is changed and only when the slider was pressed but not released.