Fnykis
7/3/2017 - 12:31 PM

Explore layer/group

Explore layer/group

function exploreLayer(layerInput) { // Input a layer object (ie. activeDocument.activeLayer) to explore.
	
	// If the layer input is a layer set, the script will iterate through the group starting from the bottom (for clipping mask reason)
	// If the layer input is an art layer it will result in the last "else" only
	
	// "layerInput" is the current layer and "layerInput.parent" is the parent group 
	
	if (layerInput.typename === "LayerSet"){
		if (layerInput.layers.length > 0){
			for (var i = layerInput.layers.length-1; i > -1; i--) exploreLayer(layerInput.layers[i]);
		} else {
			// If a group is empty
		}
	} else if (layerInput.parent == activeDocument) {
		
		// If the input layer isn't in any group at all
		
	} else {
		
		// This is the only result, if the input layer is an art layer
		
	}
	
}