def zbw_pullDownAnim():
#eventually pull these out to be two separate operations, grab controls, grab master
#select controls to pull down (create a visible list to see these controls)
controls = cmds.ls(sl=True)
controlSize = len(controls)
#select master control
master = controls[0]
def zbw_getWSTranslate(obj):
transT = cmds.xform(obj, query=True, t=True, ws=True) #gets translation from obj
#currentFrame = cmds.currentTime(query=True) #gets current frame.
return transT
def zbw_getWSRotation(obj): #do I need to decompose matrix here? or create and discard locator with rot orders
rotateT = cmds.xform(obj, query=True, ro=True, ws=True) #gets WS rotation from obj
#rotateNew = [rotateT[0][0], rotateT[0][1], rotateT[0][2]]
#currentFrame = int(cmds.currentTime(query=True)) #gets current frame.
return rotateT
#for each control selected grab the ws pos and rotation for each key, store these in a dictionary
for i in range(1,controlSize):
transKeys = {} #initialize dictionary for this control
rotKeys = {} #initialize dictionary for this control
thisControl = controls[i]
#create list of master control keys too (create set to contain keys
#from master, translate,rotate)
###### loop here for each keyframe
for nowKey in keyList:
cmds.currentTime(nowKey)
#at each key location, grab ws translation
thisTrans = zbw_getWSTranslate(thisControl)
transKeys[nowKey] = thisTrans
#at each key location, grab ws rotation/orientation
thisRot = zbw_getWSRotation(thisControl)
rotKeys[nowKey] = thisRot
###### end loop
#at each key location, apply the pos and rot
for thisKey in keyList:
cmds.setKey(thisControl, at='tx', t=thisKey, value=transKeys[thisKey[0]])
#zero out master control
#change frame rate
评论列表
文章目录