Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions ExtendScript for After Effects

  • ExtendScript for After Effects

    Posted by Anthony Honciano on October 17, 2022 at 4:29 pm

    So I’m trying to learn and teach myself ExtendScript for After Effects, and I learned how to kinda reverse engineer a layer and dial down its properties to get the property name and its Adobe Match Name. I was able to create a for loop to do this, but it only does the first “column” of properties.

    What I want: I want to be able to create a script that will display the entire hierarchy of the selected layer showing the property and its sub-properties (see image).

    Below is the code I have that just gives me the first level of property names:

    var project = app.project;
    var comp = project.activeItem;
    var lName = "test" ;
    var theLayer = comp.layer(lName)
    
    
    /*--I set a ridiculous number in the for loop so I can figure out how many properties there are. 
    Unfortunately ExtendScript (to my knowledge) won't count the length of the property group. 
    The TRY CATCH method will stop the loop.--*/
    
    for (var i=1; i<1000; i++){
        try{
            var theLayer2 = theLayer.property(i).name;
            $.writeln(i+" Name: "+theLayer.property(i).name+'\<wbr>n'+
            i+" MatchName: "+theLayer.matchName+'\n \n');
            
        } catch (e){
            break;
        }
        
        
    }
    

    This is the output I get for the selected shape layer using the above script.

    1 Name: Marker
    1 MatchName: ADBE Vector Layer
     
    
    2 Name: Contents
    2 MatchName: ADBE Vector Layer
    
    3 Name: Masks
    3 MatchName: ADBE Vector Layer
     
    
    4 Name: Effects
    4 MatchName: ADBE Vector Layer
     
    
    5 Name: Transform
    5 MatchName: ADBE Vector Layer
     
    
    6 Name: Layer Styles
    6 MatchName: ADBE Vector Layer
     
    
    7 Name: Geometry Options
    7 MatchName: ADBE Vector Layer
     
    
    8 Name: Material Options
    8 MatchName: ADBE Vector Layer
     
    
    9 Name: Audio
    9 MatchName: ADBE Vector Layer
     
    
    10 Name: Sets
    10 MatchName: ADBE Vector Layer
    Anthony Honciano replied 3 years, 6 months ago 3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    October 17, 2022 at 4:40 pm

    For each property that has sub properties, you can use numPrperties to loop through those. I think what you’ll need is a recursive function that call you whenever you encounter a property that has sub properties (PropertyType.INDEXED_GROUP or PropteryType.NAMED_GROUP) and that should let you traverse through the entire hierarchy.

  • Anthony Honciano

    October 17, 2022 at 8:13 pm

    Thank you for this! Much helpful.

  • Filip Vandueren

    October 18, 2022 at 6:53 am

    Hi Anthony, it sounds like you are re-inventing the wheel:

    these scripts are extremely useful for inspecting properties of layers:

    The original Website is down, but you can find it here:

    https://web.archive.org/web/20200810005131/http://www.redefinery.com/ae/rd_scripts/

  • Anthony Honciano

    October 27, 2022 at 9:07 am

    Oh wow! Thank you! Ya I figured that there are tools out there that already do what I’m doing lol.

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