Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Scripting: access all expressions in Comp /

  • Scripting: access all expressions in Comp /

    Posted by Matthias Stoll on April 26, 2020 at 1:50 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 <= (shape.numProperties); x++){
    try{
    for (var i = 1; i <= (shape.content(x).numProperties); i++){
    var prop = shape.content(x).property(i);
    if (prop.expressionEnabled == true) {prop.selected = true};
    }
    for (var i = 1; i <= (shape.content(x).numProperties); i++){
    for (var n = 1; n <= (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){}
    }
    }

    Matthias Stoll replied 4 years, 6 months ago 2 Members · 2 Replies
  • 2 Replies
  • Andrei Popa

    April 27, 2020 at 7:06 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.

  • Matthias Stoll

    April 27, 2020 at 7:18 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.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy