Skip to content

Instantly share code, notes, and snippets.

@splinecraft
Created December 6, 2016 00:56
Show Gist options
  • Select an option

  • Save splinecraft/82c595ce9d1e7db8bde9b3dab6fb9fa7 to your computer and use it in GitHub Desktop.

Select an option

Save splinecraft/82c595ce9d1e7db8bde9b3dab6fb9fa7 to your computer and use it in GitHub Desktop.
Set a key at the current frame and delete all other keys on selected controls/object
import pymel.core as pm
current_frame = pm.getCurrentTime()
curves = pm.findKeyframe(curve=True)
first_key = 0.0
last_key = 0.0
for curve in curves:
key = pm.findKeyframe(curve, which='first')
if key < first_key:
first_key = key
key = pm.findKeyframe(curve, which='last')
if key > last_key:
last_key = key
pm.setKeyframe(insert=True)
pm.cutKey(clear=True, time=(first_key, current_frame-1))
pm.cutKey(clear=True, time=(current_frame+1, last_key))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment