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, 09:38 PM   #1
lauris47
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, 15 views)
__________________
www.laurynaslubys.com
lauris47 is offline   Reply With Quote
Old 21-10-2017, 02:59 AM   #2
Gen
Moderator
 
Gen's Avatar
 
Join Date: Dec 2006
Location: South FL
Posts: 3,511
Default

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])
__________________
- 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 10:26 AM
Keyframe simple maya loops in python? St4rb0y Mel Scripts & Programming 0 14-07-2014 05:36 PM
Can't keyframe yolpyolpp Maya Basics & Newbie Lounge 1 20-01-2014 05:43 PM
Selecting Control Vertices Emms Technical Issues 1 04-10-2012 05:14 AM
selecting objects instead of surfaces? aebstract Maya Basics & Newbie Lounge 10 27-05-2011 12:43 PM