def toggleRelativeKeyframeDisplay(self):
        sender = self.sender()
        onionCore.viewRenderOverrideInstance.setRelativeKeyDisplay(self.sender().isChecked())

        
        futureKeys = []
        pastKeys = []

        nextKey = pm.findKeyframe(ts=True, w="next")
        pastKey = pm.findKeyframe(ts=True, w="previous")

        # add next keys to list
        bufferKey = pm.getCurrentTime()
        for i in range(self.mRelativeFrameAmount/2):
            if nextKey <= bufferKey:
                break
            futureKeys.append(nextKey)
            bufferKey = nextKey
            nextKey = pm.findKeyframe(t=bufferKey, ts=True, w="next")

        # add prev keys to list
        bufferKey = pm.getCurrentTime()
        for i in range(self.mRelativeFrameAmount/2):
            if pastKey >= bufferKey:
                break
            pastKeys.append(pastKey)
            bufferKey = pastKey
            pastKey = pm.findKeyframe(t=bufferKey, ts=True, w="previous")
Ejemplo n.º 2
0
    def toggleRelativeKeyframeDisplay(self):
        sender = self.sender()
        onionCore.viewRenderOverrideInstance.setRelativeKeyDisplay(
            self.sender().isChecked())

        futureKeys = []
        pastKeys = []

        nextKey = pm.findKeyframe(ts=True, w="next")
        pastKey = pm.findKeyframe(ts=True, w="previous")

        # add next keys to list
        bufferKey = pm.getCurrentTime()
        for i in range(self.mRelativeFrameAmount / 2):
            if nextKey <= bufferKey:
                break
            futureKeys.append(nextKey)
            bufferKey = nextKey
            nextKey = pm.findKeyframe(t=bufferKey, ts=True, w="next")

        # add prev keys to list
        bufferKey = pm.getCurrentTime()
        for i in range(self.mRelativeFrameAmount / 2):
            if pastKey >= bufferKey:
                break
            pastKeys.append(pastKey)
            bufferKey = pastKey
            pastKey = pm.findKeyframe(t=bufferKey, ts=True, w="previous")
Ejemplo n.º 3
0
def key_delete(all_keys=True, only_before=False):
    """Delete all keys before, after, or both, except the current one which has an insert key set"""
    current_frame = pm.getCurrentTime()
    curves = pm.findKeyframe(curve=True)

    first_key = 0.0
    last_key = 0.0

    for curve in curves:
        key = pm.findKeyframe(curve, which='first')
        if key < first_key:
            first_key = key
        key = pm.findKeyframe(curve, which='last')
        if key > last_key:
            last_key = key

    pm.setKeyframe(insert=True)
    if not all_keys:
        if only_before:
            pm.cutKey(clear=True, time=(first_key, current_frame - 1))
        else:
            pm.cutKey(clear=True, time=(current_frame + 1, last_key))
    else:
        pm.cutKey(clear=True, time=(first_key, current_frame - 1))
        pm.cutKey(clear=True, time=(current_frame + 1, last_key))
    def setRelativeFrames(self, value):
        if not self.mRelativeKeyDisplay:
            return
        
        nextKeys = []
        pastKeys = []

        nextKey = pm.findKeyframe(ts=True, w="next")
        pastKey = pm.findKeyframe(ts=True, w="previous")

        # add next keys to list
        bufferKey = pm.getCurrentTime()
        for i in range(4):
            if nextKey <= bufferKey:
                break
            nextKeys.append(nextKey)
            bufferKey = nextKey
            nextKey = pm.findKeyframe(t=bufferKey, ts=True, w="next")

        # add prev keys to list
        bufferKey = pm.getCurrentTime()
        for i in range(4):
            if pastKey >= bufferKey:
                break
            pastKeys.append(pastKey)
            bufferKey = pastKey
            pastKey = pm.findKeyframe(t=bufferKey, ts=True, w="previous")


        pastKeys = list(reversed(pastKeys))

        for frameIndex in self.mRelativeOnions:
            blendPass = self.mRelativeOnions[frameIndex]
            if frameIndex < 0:
                # past
                if pastKeys and len(pastKeys) >= frameIndex*-1:
                    blendPass.setActive(True)
                    blendPass.setFrame(pastKeys[frameIndex])
                else:
                    blendPass.setActive(False)
            else: 
                # future
                if nextKeys and len(nextKeys) >= frameIndex:
                    blendPass.setActive(True)
                    blendPass.setFrame(nextKeys[frameIndex-1])
                else:
                    blendPass.setActive(False)
Ejemplo n.º 5
0
def paste_keys_merge():
    """paste keys merge at current frame"""
    current_frame = pm.getCurrentTime()
    pm.pasteKey(option='merge', time=(current_frame,))
Ejemplo n.º 6
0
def paste_keys_insert():
    """paste keys insert at current frame"""
    current_frame = pm.getCurrentTime()
    pm.pasteKey(option='insert', connect=True, time=(current_frame,))
Ejemplo n.º 7
0
 def __enter__(self):
     self.oldt = pmc.getCurrentTime()
     pmc.setCurrentTime(self.t)
Ejemplo n.º 8
0
 def __enter__(self):
     self.oldt = pmc.getCurrentTime()
     pmc.setCurrentTime(self.t)
Ejemplo n.º 9
0
 def testAtTime(self):
     pmc.setCurrentTime(1)
     with at_time(2):
         self.assertEqual(pmc.getCurrentTime(), 2)
     self.assertEqual(pmc.getCurrentTime(), 1)
Ejemplo n.º 10
0
 def testAtTime(self):
     pmc.setCurrentTime(1)
     with at_time(2):
         self.assertEqual(pmc.getCurrentTime(), 2)
     self.assertEqual(pmc.getCurrentTime(), 1)
Ejemplo n.º 11
0
 def testAtTime(self):
     pmc.setCurrentTime(1)
     with utils.atTime(2):
         print(type(pmc.getCurrentTime()))
         self.assertEqual(pmc.getCurrentTime(), 2)
     self.assertEqual(pmc.getCurrentTime(), 1)