ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Scripting: access all expressions in Comp /

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Matthias Stoll
Scripting: access all expressions in Comp /
on Apr 26, 2020 at 1:50:46 pm

Hello all,

I need to find a way to adress all expressions (activated / deactivated) in one Comp. My project is a custom expression-baker. With bigger expression rigs it is inconvenient to lasso-select all expression properties and then use the "Convert Expressions to keyframes" command. I want to bake & unbake all expressions with one click.

My solution so far was to build different kinds of for-loops, entering every property and every properties property checking if there is an (expressionActivated == true).

This works okay for selecting all active expressions, but if I want to select all inactive Expression, this does not work. Because a property with (expressionActivated == false) can also have no expression at all. Also it is not a very clean solution, because the script can not know how many branches the property-tree has before the expression.

I believe there must be a way to access all expressions in another way. But I can't find any info about this in the Toolguide or other resources... The code I attached is just an example how I am doing it (selecting the properties) right now - it may not have much to do with the solution I am looking for.

Any hint would be very much appreciated!!!

var selectShapeProps_2 = function(c){
var shape = layer.content(c)


for (var x = 1; x &lt;= (shape.numProperties); x++){
try{
for (var i = 1; i &lt;= (shape.content(x).numProperties); i++){
var prop = shape.content(x).property(i);
if (prop.expressionEnabled == true) {prop.selected = true};
}
for (var i = 1; i &lt;= (shape.content(x).numProperties); i++){
for (var n = 1; n &lt;= (shape.content(x).content(i).numProperties); n++){
var prop2 = shape.content(x).content(i).property(n);
if (prop2.expressionEnabled == true) {prop2.selected = true};
}
}
}catch(err){}
}
}


Return to posts index

Andrei Popa
Re: Scripting: access all expressions in Comp /
on Apr 27, 2020 at 7:06:44 am

I do not know of any way to select all expressions in a composition.
I think you need to use your current method and just loop through all the properties.

But to check if property has expressions, use this: if(property.expression != undefined)

Andrei
My Envato portfolio.


Return to posts index

Matthias Stoll
Re: Scripting: access all expressions in Comp /
on Apr 27, 2020 at 7:18:23 am

Thank you!! Now I am not stuck anymore!

I also read about for... in... Loops in the extend script manual. They are supposed to be good for “looping through properties”. I still haven’t figured them out, but I have hopes they give me a cleaner solution.


Return to posts index

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