import maya.cmds as cmds
def MinimizeRotationCurves(obj):
'''
Sets rotation animation to the value closest to zero.
'''
rotateCurves = cmds.keyframe(obj, attribute=('rotateX','rotateY', 'rotateZ'), query=True, name=True)
if not rotateCurves or len(rotateCurves) < 3:
return
keyTimes = cmds.keyframe(rotateCurves, query=True, timeChange=True)
tempFrame = sorted(keyTimes)[0] - 1
#set a temp frame
cmds.setKeyframe(rotateCurves, time=(tempFrame,), value=0)
#euler filter
cmds.filterCurve(rotateCurves)
#delete temp key
cmds.cutKey(rotateCurves, time=(tempFrame,))
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme