SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Animation / Selecting every second keyframe
Register FAQ Members List Calendar Mark Forums Read

New Thread
Thread Tools
Old 14-10-2017, 08:38 PM   #1
Registered User
Join Date: Sep 2011
Posts: 104
Default Selecting every second keyframe

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.
Attached Images
File Type: jpg Everysecond.jpg (190.4 KB, 23 views)
lauris47 is offline   Reply With Quote
Old 21-10-2017, 01:59 AM   #2
Gen's Avatar
Join Date: Dec 2006
Location: South FL
Posts: 3,513

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.

import maya.cmds as mc

object = =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])
- Genny
::|| My CG Blog ||::
::|| My Maya FAQ ||::
Gen is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy a keyframe and get everything with it jttraverse Maya Basics & Newbie Lounge 8 11-06-2016 09:26 AM
Keyframe simple maya loops in python? St4rb0y Mel Scripts & Programming 0 14-07-2014 04:36 PM
Can't keyframe yolpyolpp Maya Basics & Newbie Lounge 1 20-01-2014 04:43 PM
Selecting Control Vertices Emms Technical Issues 1 04-10-2012 04:14 AM
selecting objects instead of surfaces? aebstract Maya Basics & Newbie Lounge 10 27-05-2011 11:43 AM