Created
January 13, 2023 15:40
-
-
Save BigRoy/ecf450f9f5a0ae0a59651bbb06eb2af5 to your computer and use it in GitHub Desktop.
Maya Python code example on how to shift animation keys for an export
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from maya import cmds | |
import contextlib | |
@contextlib.contextmanager | |
def offsetted_keys(offset, nodes=None): | |
if nodes is None: | |
# Apply to all time-based animation curves (excluding driven keys) | |
nodes = cmds.ls(type=("animCurveTL","animCurveTU","animCurveTA","animCurveTT")) | |
try: | |
cmds.keyframe(nodes, edit=True, relative=True, selected=False, timeChange=offset) | |
yield | |
finally: | |
cmds.keyframe(nodes, edit=True, relative=True, selected=False, timeChange=-offset) | |
start = 30 | |
with offsetted_keys(-start): | |
# Implement your export logic here | |
export() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment