Free Function Friday Ep.2 – getLayerEffects

October 02nd 2015 08:00:47am

All of the code I provide in this series, has been created and tested in After Effects CC 2014. Unless otherwise specified in the episode, the code should be compatible with After Effects CS6 and newer. There may be future unexpected changes by Adobe though.

I’ve done my best to avoid depreciated code (code that Adobe removed previously at some point), and made these functions as compatible as possible. There will however be the occasional piece of code that is brand new as of a certain version of After Effects and therefore will not be backwards compatible from that version. I will mention these if that is the case.

With that said, all the code I provide in this series is open source and free to use in your scripts. I highly encourage you to expand and improve upon the code I provide and start making your own custom functions as well, but please do not repost the code I show in this series as is and claim it as your own.

If you use any of the code provided in this series please give credit where credit is due. This series is meant to provide, what I feel is useful code, as well as to hopefully further explain ExtendScript and it’s quirks.

While the functions we build throughout this series can perform a task all on their own, they are not meant to be a solo script. How you combine them together and expand upon them is when you will gain the most from these functions.

Source Code:

function getLayerEffects(layerObj, aryList){
	var np = layerObj.numProperties;
	var propNames = new Array();
	for(var i=1; i<=np; i++){
		var curProp = layerObj.property(i);
		if(curProp.matchName == "ADBE Effect Parade"){
			var propDepth = curProp.numProperties;
			if(propDepth > 0){
				for(var p=1; p<=propDepth; p++){
					propNames[propNames.length] = curProp.property(p).name + " = " + curProp.property(p).matchName;
				}
			}
		}
	}
	if(aryList == "Ary"){
		return propNames;
	}else if(aryList == "List"){
		return propNames.toString().replace(new RegExp(",", "g"),"\r");
	}
}

alert(getLayerEffects(app.project.activeItem.layer(1), "List"));
Checkout more:
Expression Shorts Auto Layer Offset 2D
Free Function Friday Ep.22 – getLightType
Stabilize Footage After Effects Script
Houdini Mardini Perch
Free Function Friday Ep.27 – currentTime