Skip to content

Instantly share code, notes, and snippets.

@gregtemp
Created June 5, 2014 18:04
Show Gist options
  • Save gregtemp/92d1ac6f879be7dc9082 to your computer and use it in GitHub Desktop.
Save gregtemp/92d1ac6f879be7dc9082 to your computer and use it in GitHub Desktop.
Key full rotation of selected objects - in Maya
#keyRotation.py
import maya.cmds as cmds
def keyFullRotation (pObjectName, pStartTime, pEndTime, pTargetAttribute) :
cmds.cutKey(pObjectName, time=(pStartTime, pEndTime), attribute=pTargetAttribute)
cmds.setKeyframe(pObjectName, time=pStartTime, attribute=pTargetAttribute, value = 0)
cmds.setKeyframe(pObjectName, time=pEndTime, attribute=pTargetAttribute, value=360)
cmds.selectKey(pObjectName, time=(pStartTime, pEndTime), attribute=pTargetAttribute, keyframe=True)
cmds.keyTangent(inTangentType='linear', outTangentType='linear')
selectionList = cmds.ls( selection = True, type='transform')
if len(selectionList) >= 1:
#print( 'Selected Items: %s' %(selectionList))
startTime = cmds.playbackOptions(query = True, minTime = True)
endTime = cmds.playbackOptions(query = True, maxTime = True)
for objectName in selectionList:
#objectTypeResult = cmds.objectType( objectName )
#print ('-- %s is of type %s' %( objectName, objectTypeResult))
keyFullRotation(objectName, startTime, endTime, 'rotateY')
else:
print (' Please select at least one object' )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment