Skip to content

Instantly share code, notes, and snippets.

@RedForty
Created May 24, 2018 08:59
Show Gist options
  • Save RedForty/3b597e739b57eaf623e29b6e5861b266 to your computer and use it in GitHub Desktop.
Save RedForty/3b597e739b57eaf623e29b6e5861b266 to your computer and use it in GitHub Desktop.
import maya.cmds as cmds
import selectedAttributes
sel = cmds.ls(selection=True)
if cmds.scaleKey(attribute=True): # Is a key/curve selected?
keys = cmds.keyframe(sel, query=True, selected=True) or []
attributes = cmds.keyframe(sel, query=True, selected=True, name=True) or []
first_key = min(keys)
last_key = max(keys)
mid_pivot = (first_key + last_key) / 2
for attribute in attributes:
cmds.scaleKey(attribute, time=(first_key, last_key), timeScale=-1, timePivot=mid_pivot )
else:
channel_attributes = selectedAttributes.get()
list_of_keys = []
for attribute in channel_attributes:
list_of_keys.extend(cmds.keyframe(attribute, query=True) or [])
first_key = min(list_of_keys)
last_key = max(list_of_keys)
mid_pivot = (first_key + last_key) / 2
for attribute in channel_attributes:
cmds.scaleKey(attribute, time=(first_key, last_key), timeScale=-1, timePivot=mid_pivot )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment