Expressions
Linear
Inverted Rounded Corners Rectangle
Get the number of layers in this comp
Move along the edges of the comp
Move in a square
Move in a circle
Determine Acceleration / Deceleration
Reset path location + ignore transforms
Scripting
Paint ScriptUI StaticText
Paint ScriptUI Panels & Groups
Refresh Panel or Group Graphics
Remove Children from ScriptUI Items
Get / Set Render Chime Preference
JSON functions for expressions
Modulate a number
Clamp Number Or Array of Numbers
Shift, Ctrl, Alt, Key Pressed functions
Contact Gumroad through ExtendScript
Get Project Items By Name
Separate Groups And Properties
Freeze Layer At Time
Filter Color Properties
lerp
Generate a random number
Mouse Object
Useful things to include in your ExtendScript file
True After Effects Color Picker
Dockable ScriptUI Panel
Check Current OS (Win / MacOS)
Smart Property Lookup
Check / Set JavaScript engine
Get the layer of the selected property
Return all existing effects on a layer

Copied!

May 18, 2020
After Effects script
Smart Property Lookup

It loops through all properties of a layer/layers and finds only the one with a specific matchName or name. You can decide whether to look for two different kinds of properties or to look for a property that passes both conditions (name & matchname)

Good Boy Ninja
75% OFF
EVERYTHING
USE CODE: WORLDEND
9
Days
99
Hours
99
Minutes
99
Seconds
Promo ends 30 Aug, 20:00 UTC
Expression

function SmartPropertyLookup(specificLayers, nameOrMatch1, nm1, andOr, nameOrMatch2, nm2) {

     try {

       //recursive function to look for all properties that exist

       function getProperties(currentProperty, propertyMatchName, propertyMatchName2, propsArray) {

         propsArray = propsArray || [];

         for (var i = 1, il = currentProperty.numProperties; i <= il; i++) {

           switch (nameOrMatch1) {

             case ("matchName"):

               var condition1 = currentProperty.property(i).matchName === propertyMatchName;

               break;

             case ("name"):

               var condition1 = currentProperty.property(i).name === propertyMatchName;

               break;

           }


           switch (nameOrMatch2) {

             case ("matchName"):

               var condition2 = currentProperty.property(i).matchName === propertyMatchName2;

               break;

             case ("name"):

               var condition2 = currentProperty.property(i).name === propertyMatchName2;

               break;

           }


           if (andOr !== undefined && andOr.length > 0) {

             switch (andOr) {

               case ("and"):

                 var execCompare = condition1 && condition2;

                 break;

               case ("or"):

                 var execCompare = condition1 || condition2;

                 break;

             }

           } else {

             var execCompare = condition1

           }

           if (execCompare) {

             propsArray.push(currentProperty.property(i));

           }

           getProperties(currentProperty.property(i), propertyMatchName, propertyMatchName2, propsArray);

         }

         //alert(propsArray);

         return propsArray;

       }


       var composition = app.project.activeItem;

       if (!composition || !(composition instanceof CompItem)) {

         return; //alert("Please select composition first");

       }

       // will scan all layers in comp by default, unless some layers are selected

       //  alert(specificLayers == undefined);

       if (specificLayers == undefined || specificLayers == "" || specificLayers == null) {

         var selectedLayers = composition.numLayers;

         var scanLength = composition.numLayers;

         var initialIncrementFix = 1;

         var scanMe = composition.layers;


       } else {

         if (specificLayers.length > 0) {

           if (specificLayers.length > 1) {

             var selectedLayers = specificLayers;

             var scanLength = specificLayers.length;

             var initialIncrementFix = 0;

             var scanMe = selectedLayers;

           } else {

             var selectedLayers = specificLayers;

             var initialIncrementFix = 0;

             var scanLength = 1;

             var scanMe = selectedLayers;

           }

         } else {

           var selectedLayers = [specificLayers];


           var initialIncrementFix = 0;

           var scanLength = 1;

           var scanMe = selectedLayers;

         }

       }


       var layer;

       var propertyToLookFor;

       propertiesFound = [];


       // For each selected layer

       for (var i = 0, il = scanLength; i < il; i++) {

         layer = scanMe[i + initialIncrementFix];

         propertyToLookFor = getProperties(layer, nm1, nm2);

         //Loop through all "ADBE Vector Shape" properties and do your magic

         for (var j = 0, jl = propertyToLookFor.length; j < jl; j++) {

           propertiesFound.push(propertyToLookFor[j]);

         }

       }

       //alert(propertiesFound);

       return propertiesFound;

     } catch (e) {

       alert("Smart Property Lookup Failed");

       return false;

     }

   }

Pricing
Make Money
Support
Blog