ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Script to Toggle Hold Keyframe property

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Zachary Kurth-Nelson
Script to Toggle Hold Keyframe property
on Dec 30, 2010 at 12:10:20 am

Is there a way using an After Effects script to toggle a keyframe's Toggle Hold Keyframe property?

(If anyone's curious why I would want to do this, I've been developing a script that inserts about 300,000 opacity keyframes in about 1,000 masks in a few different layers over a duration of about 30 seconds. Each mask was created using autotrace by luminosity and when they're put together they divide the picture a bit like broken glass. The script I wrote allows me to set the probability that the next keyframe will be opacity 100 or 0, and the to randomly select the time to the next keyframe between a designated number of frames set by me and evolving over time. It's a pretty neat effect.)

It's easy enough to make a function that inserts another keyframe before the next opacity change, but already the script takes about an hour to run because inserting that many keyframes bogs it down a bit (plus the extra operations it has to run). Not having to insert all those extra keyframes would be super duper.

Toggle Hold Keyframe would be the obvious solution, but it also becomes odious to manually select all 300,000+ of those keyframes in order to Toggle that, especially when I have to redo this over and over as I play around with my probability values to get exactly the effect I want for the final product.

So, again, does each keyframe have a set of properities I can access, with Toggle Hold being one of those? If so, what's the code for that?

Thanks so much in advance to anyone who might have the solution for this!

Return to posts index

Zachary Kurth-Nelson
Re: Script to Toggle Hold Keyframe property
on Dec 30, 2010 at 12:49:42 am

Well, I found my own answer (it's the golden rule of programming - you can look for hours for the answer and then as soon as you ask someone else for help it just pops in front of you).

It's the setInterpolationTypeAtKey() method.

A quick example for anyone who encountered the same problem and would like a brief bit of code to nibble on:

var layerVar = app.project.activeItem.layer(layerLoopCount);
var layerMasks ="Masks");
var currentMask = layerVar.mask(1);
var maskOpacity = currentMask("Mask Opacity");

maskOpacity.setValueAtTime(0, 100); // creates a mask at frame 0 with opacity 100
maskOpacity.setInterpolationTypeAtKey(1, KeyframeInterpolationType.HOLD); // sets the interpolation type of the 1st keyframe in the mask to hold

The documentation was found on page 133 of the CS3 Adobe After Effects Professional Scripting Guide:

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 All Rights Reserved