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
Thanks: 11
Thanked 11 Times in 11 Posts
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, 13 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,501
Thanks: 16
Thanked 645 Times in 567 Posts
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

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.