SimplyMaya Forums

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

SM Forums / Maya Questions / Animation / Selecting every second keyframe

Animation Animation & Rigging Related Topics

Join the conversation. Reply to post
Thread Tools
14-10-2017, 08:38 PM   #1
Registered User
Join Date: Sep 2011
Posts: 109
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 Thumbnails
Click image for larger version

Name:	Everysecond.jpg
Views:	308
Size:	190.4 KB
ID:	57605  
  Reply with quote
21-10-2017, 01:59 AM   #2
Super Moderator
Gen's Avatar
Join Date: Dec 2006
Location: South FL
Posts: 3,518
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 ||::
  Reply with quote

Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Keyframe Depth of Field? mindbend Maya Basics & Newbie Lounge 11 29-05-2018 09:52 PM
How to copy a keyframe and get everything with it jttraverse Maya Basics & Newbie Lounge 8 11-06-2016 09:26 AM
Selecting Groups of Verticles kotsuki84 Maya Basics & Newbie Lounge 1 17-04-2009 09:06 AM
Keyframe mel Velusion Programming 7 06-04-2006 04:28 PM
Selecting faces without selecting the back faces jezzaH Maya Modeling 2 16-11-2004 03:50 PM