Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Skipping Hidden Properties with ExtendScript

  • Skipping Hidden Properties with ExtendScript

    Posted by Keenan Parry on October 2, 2019 at 5:17 pm

    Hey there, I have this script that scrubs through the active comp and automatically enables all expressions that are disabled in the comp. This works great until the composition has “Hidden Properties” and it gives me an error. Basically any effect like Grid or a Light Layer that will hide properties that are being unused. Those stop the script dead in its tracks and I’d like to make a Try Catch to simply skip these properties and move onto the next one. However, I’m having trouble implementing this as I’m new to extendscript. I’ve seen things like PropertyValueType.NO_VALUE or CUSTOM_VALUE, but I’m kinda lost on how to get this to work. Any help is appreciated!

    (function() {
    function recursiveDisableExpressions(propertyGroup) {
    for (var i = 1; i <= propertyGroup.numProperties; i++) {
    var property = propertyGroup.property(i);

    if (property instanceof PropertyGroup) {
    recursiveDisableExpressions(property);
    continue;
    }

    if (!property.canSetExpression) {
    continue;
    }

    if (!property.isModified) {
    continue;
    }

    if (property.expressionEnabled === false) {
    property.expressionEnabled = true;
    }
    }
    }

    app.beginUndoGroup("Disable All Comp Expressions");

    var comp = app.project.activeItem;

    for (var i = 1; i <= comp.numLayers; i++) {
    var layer = comp.layer(i);

    recursiveDisableExpressions(layer);
    }

    app.endUndoGroup();
    })();

    Matthias Stoll
    replied 4 years, 11 months ago
    3 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    October 2, 2019 at 5:57 pm

    Can you give a specific example of how to set up something that will generate an error?

    Dan

  • Keenan Parry

    October 2, 2019 at 6:18 pm

    Hi Dan, thanks for the reply. It wasn’t as easy to explain as I thought, so I made a little demo AEP file for you if you’re willing to take the time. I set it up as easy and straightforward as possible.

    https://www.dropbox.com/s/o7dj152x0uafvs8/Error_Demo.aep?dl=0

    If you open that file you will see 3 layers. The layer in question that’s causing the problem is the Grid effect on the layer called ERROR I believe? Possibly the grayed out Width and Height section? When you run the script, you will see the error pop up and after you stop the script, you will notice that it does actually enable the first two expressions but stops before it can enable the 3rd at the bottom.

  • Dan Ebberts

    October 2, 2019 at 6:23 pm

    Ah, thanks.

    Just adding a try/catch worked for me:


    try{
    property.expressionEnabled = true;
    }catch (e){
    }

    Dan

  • Keenan Parry

    October 2, 2019 at 6:28 pm

    Thanks Dan! Do you mind showing me where you put it in the full script? I attempted to put it in front of all the if statements and then after but I’m still getting the error.

  • Dan Ebberts

    October 2, 2019 at 6:31 pm


    (function() {
    function recursiveDisableExpressions(propertyGroup) {
    for (var i = 1; i <= propertyGroup.numProperties; i++) {
    var property = propertyGroup.property(i);

    if (property instanceof PropertyGroup) {
    recursiveDisableExpressions(property);
    continue;
    }

    if (!property.canSetExpression) {
    continue;
    }

    if (!property.isModified) {
    continue;
    }

    if (property.expressionEnabled === false) {
    try{
    property.expressionEnabled = true;
    }catch (e){
    }
    }
    }
    }

    app.beginUndoGroup("Disable All Comp Expressions");

    var comp = app.project.activeItem;

    for (var i = 1; i <= comp.numLayers; i++) {
    var layer = comp.layer(i);

    recursiveDisableExpressions(layer);
    }

    app.endUndoGroup();
    })();

  • Keenan Parry

    October 2, 2019 at 6:34 pm

    Once again, you have helped me directly as much as you have helped me indirectly. Thank you sir.

  • Matthias Stoll

    April 28, 2020 at 2:19 pm

    This method is great to select/adress all properties in a Comp. It was hard to find this here because your use case here is different.

    I’ve been trying to build this for some time now, never got it. I could not come up with the construct that the property becomes the function input as soon as it is “instanceof PropertyGroup”.

    I found out this doesn’t work for Mask Properties. But it is really easy to fix, just modify the first if-Statement to include “MaskPropertyGroup”.

    if (property instanceof PropertyGroup || property instanceof MaskPropertyGroup) {
    recursiveDisableExpressions(property);
    continue;

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