Hi everyone,
I am a still beginner at Extendscript. How could I store selected keyframes so I can delete them afterwards. I have tried arrays but I am missing something. This is the simplified version:
var keySelection = property.selectedKeys;
for (i = keySelection[0]; i < keySelection.length; i++) {
property.removeKey(i)
}
I am writing a script that will move keys to a specific time in milliseconds,secs or frames.. the button is aware of the comp frame-rate and you would be able to move to the selected keys to a typed specific time.
Thanks,
Sebastian
Delete Selected Keyframes via script
Moderator: Paul Tuersley
-
- Posts: 16
- Joined: December 8th, 2014, 11:11 pm
I think what you were going for is this:
The problem with that is that as you're removing keyframes, the current indexes of the keyframes reduce by one, but your original keySelection indexes stay the same. The way you can get around that is to subtract the number of times you've already removed a keyframe:
Code: Select all
var keySelection = property.selectedKeys;
for (i = 0; i < keySelection.length; i++) {
property.removeKey(keySelection[i]);
}
Code: Select all
var keySelection = property.selectedKeys;
for (i = 0; i < keySelection.length; i++) {
property.removeKey(keySelection[i]-i);
}
-
- Posts: 5
- Joined: November 4th, 2017, 9:36 am
- Location: Germany
Hi Jordan
That did the trick.So good to know this, no idea that the indexes stay the same, because apparently ae deselects after deleting a keyframe.
Thanks a lot.
That did the trick.So good to know this, no idea that the indexes stay the same, because apparently ae deselects after deleting a keyframe.
Thanks a lot.
-
- Posts: 5
- Joined: November 4th, 2017, 9:36 am
- Location: Germany
I am struggling now with the layers. So it will delete all keyframes from all selected properties from selected layers.
AE deletes the selected keyframes form the first selected property from the first selected Layer--good until then
. After that, looks like the selection goes to hell and is like nothing was selected in the fist place, so It can't move to the next selected property to continue deleting frames
.
AE deletes the selected keyframes form the first selected property from the first selected Layer--good until then


Code: Select all
var layers = comp.selectedLayers;
var properties = comp.selectedProperties;
for (var j = 0; j < layers.length; j++) {
for (var k = 0; k < properties.length; k++) {
if (properties[k] instanceof Property){
var keySelection = property.selectedKeys;
for (var i = 0; i < keySelection.length; i++) {
property.removeKey(keySelection[i]-i); }
}
}
}
-
- Posts: 81
- Joined: November 27th, 2012, 6:41 am
property is not defined in your snippet.
(You need define : var property = property[k])
Xavier
(You need define : var property = property[k])
Xavier