Introduction to Maya - Modeling Fundamentals Vol 1
This course will look at the fundamentals of modeling in Maya with an emphasis on creating good topology. We'll look at what makes a good model in Maya and why objects are modeled in the way they are.
# 1 14-10-2017 , 08:38 PM
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
# 2 21-10-2017 , 01:59 AM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
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 ||::
Posting Rules Forum 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