splinecraft
12/6/2016 - 12:56 AM

Set a key at the current frame and delete all other keys on selected controls/object

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))