ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Running an expression a single time

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Nickolas Howell
Running an expression a single time
on Sep 7, 2018 at 9:56:59 pm

Hey everyone!
New to the community.

I'm working on some JSON related expressions that need to sort through a list.
Once the list is large (10k+ items) this can become quite tedious and I believe the sort runs on every individual frame.

Is there a way for me to run the expression a single time?
Can I use valueAtTime() or something similar to trick after effects?

Thanks for the assistance!
Nick

data = footage("JSON-Input.json").sourceData.data;
var arr = [];

for (obj in data) {
arr.push(data[obj].high);
}

Math.max.apply(null, arr);


Return to posts index

Dan Ebberts
Re: Running an expression a single time
on Sep 8, 2018 at 12:00:54 am

Supposedly, you can limit an expression's execution to exactly once by including this comment in the expression:

// cacheCompareSamplesPerSecond 0

I can't personally verify that it works, but it was in the release notes for AE CC 2014.

If it works for you, please report back.


Dan



Return to posts index

Nickolas Howell
Re: Running an expression a single time
on Sep 8, 2018 at 12:30:30 am

Thanks Dan!

This is an interesting find but I don't seem to get any performance improvement from it.

After it seemingly didn't work, I decided to test it on an ease function to test if it would cause the ease functions first value to become stale throughout the rest of the timeline and it did not.

It was still worth a shot!
Nick


Return to posts index


Nickolas Howell
Re: Running an expression a single time
on Sep 8, 2018 at 2:21:55 am

Update:

Dan,

That command actually gave me an 800% speed increase!
It turned out I had to use a very simple line of a code for it to work. Anything complex or potenially dynamic, and the line would disable itself it seemed. I ended up taking single execution pieces of math inside variable output expressions and putting them into slider controls. From there I could use the snippet you gave me and it would execute a single time. Then I could reference the slider in my main code.

Thanks for the help!
Nick


Return to posts index

Dan Ebberts
Re: Running an expression a single time
on Sep 8, 2018 at 6:05:28 am

Good to know. Thanks for the info!

Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]