SimplyMaya Forums

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


Go Back   Simply Maya User Community / Animation / Animation

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

Name:	Everysecond.jpg
Views:	48
Size:	190.4 KB
ID:	57605  
__________________
www.laurynaslubys.com
lauris47 is offline   Reply With Quote
Old 21-10-2017, 01:59 AM   #2
Gen
Moderator
 
Gen's Avatar
 
Join Date: Dec 2006
Location: South FL
Posts: 3,513
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
Reply

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

BB 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 05: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

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.