SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import maya.cmds as cmds
  2.  
  3. def blendToNeighbours(move = 20):
  4.  
  5.     # Get a selected key information
  6.     sel_channelName = cmds.keyframe(query=1, name=1)[0]  # name
  7.     sel_time = cmds.keyframe(query=1, timeChange=1)[0] # frame
  8.     sel_value = cmds.keyframe(query=1, valueChange=1)[0] # value
  9.     sel_index = cmds.keyframe(query=1, indexValue=1)[0]
  10.  
  11.     # Get neighbour frames
  12.     prevFrame = cmds.findKeyframe(which = "previous", time = (sel_time,sel_time))
  13.     nextFrame = cmds.findKeyframe(which = "next", time = (sel_time,sel_time))
  14.  
  15.     # get neighbour values
  16.     cmds.selectKey(clear=1)
  17.     #for "time" attribute we use time range in brackets, like  time=(15,49)
  18.     prevValue = cmds.keyframe(sel_channelName, query=1, time=(prevFrame,prevFrame), valueChange=1)[0]
  19.     nextValue = cmds.keyframe(sel_channelName, query=1, time=(nextFrame,nextFrame), valueChange=1)[0]
  20.     cmds.selectKey(sel_channelName, time=(sel_time,sel_time))
  21.  
  22.     # sel_value , prevValue, nextValue
  23.     nStep = (nextValue - sel_value)/100
  24.     pStep = (sel_value - prevValue)/100
  25.  
  26.     #do blend
  27.     if move > 0: # move to the next
  28.         newValue = sel_value + move * nStep
  29.     elif move < 0: # move to the prev
  30.         newValue = sel_value + move * pStep
  31.  
  32.     cmds.keyframe(valueChange = newValue)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top