splinecraft
1/9/2019 - 1:35 AM

invert key values

inverts selected keyframe values (* -1)

import maya.cmds as cmds

curves = cmds.keyframe(q=True, sl=True, n=True)

if curves:
    for curve in curves:
        key_times = cmds.keyframe(curve, q=True, sl=True, tc=True)
        key_vals = cmds.keyframe(curve, q=True, sl=True, vc=True)
        for i, frame in enumerate(key_times):
            cmds.keyframe(curve, e=True, time=(frame,frame), absolute=True, vc=(key_vals[i]*-1))
else:
    cmds.warning('No keys selected')