ml_utilities.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:ml_tools 作者: morganloomis 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号