Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Animation (https://simplymaya.com/forum/forumdisplay.php?f=14)
-   -   Selecting every second keyframe (https://simplymaya.com/forum/showthread.php?t=43213)

lauris47 14-10-2017 08:38 PM

Selecting every second keyframe
 
1 Attachment(s)
Hi, is there a way to select every second or nth frame?
I have ~hundred frames - baked range, and to create shivering effect I need to select each second key-frame.
Doing it manually would take ~10 minutes every time.

Gen 21-10-2017 01:59 AM

Run this code in a Python tab. The "2" popping up throughout the code just means that while looping through the list, it will act on every other item, essentially its your "nth item" value. Let me know if there are any issues.

Code:

import maya.cmds as mc

object = mc.ls(selection =True)[0]
keys = mc.keyframe(object, query =True)

i = 0
while i < len(keys):
        mc.selectKey(object, k =True, time = (keys[i], keys[i]), add =True)
        i = i+2
print "Selected " + str(len(keys[::2])) + " keys: ", str(keys[::2])



All times are GMT. The time now is 02:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018