Created
June 16, 2016 17:35
-
-
Save dokluch/a9f4b43080deb05af2121e6a68110df2 to your computer and use it in GitHub Desktop.
This snippet will remove every other key on a selected property starting from 0 or 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Remove every second keyframe for selected property | |
var start = 0; //Start with 0 or 1 | |
var activeComp = app.project.activeItem; | |
if(activeComp && activeComp instanceof CompItem){ | |
var sel = activeComp.selectedProperties; | |
if(sel.length > 0){ | |
app.beginUndoGroup("Remove every 2nd"); | |
sel = sel[0]; //Getting selected parent property | |
for(var s = sel.numProperties; s > 0; s--){ | |
//getting a sub-property with keyframes on it | |
if(sel.property(s).isTimeVarying){ | |
if(sel.property(s).numKeys > 0){ | |
sel = sel.property(s); | |
break; | |
} | |
} | |
} | |
if(sel.numKeys > 0){ | |
for(var k = sel.numKeys; k > 0; k--){ | |
if(k%2 == start){ | |
sel.removeKey(k); | |
k--; | |
} | |
} | |
} | |
app.endUndoGroup(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment