def findKeyframe(self, which='next', loop=False, roundFrame=False, **kwargs):
'''
This is similar to maya's findKeyframe, but operates on the keySelection and has options
for rounding and looping.
'''
if which not in ('next','previous','first','last'):
return
if not roundFrame:
if not loop or which == 'first' or which == 'last':
#if there's not special options, just use default maya command for speed
return mc.findKeyframe(self.args, which=which, **kwargs)
keyTimes = self.getSortedKeyTimes()
#if we don't find any, we're done
if not keyTimes:
return
tolerence = 0.0
if roundFrame:
tolerence = 0.5
if which == 'previous':
findTime = keyTimes[-1]
for x in reversed(keyTimes):
if self.currentTime - x > tolerence:
findTime=x
break
elif which == 'next':
findTime = keyTimes[0]
for x in keyTimes:
if x - self.currentTime > tolerence:
findTime=x
break
elif which == 'first':
findTime = keyTimes[0]
elif which == 'last':
findTime = keyTimes[-1]
if roundFrame:
#round to nearest frame, if that option is selected
findTime = round(findTime)
return findTime
评论列表
文章目录