Hey folks,
does anyone know if its possible to loop through a docs layers and return them based on layer bounds?
For example I want layer data returned in order based on the top margin layer bound, so layers that are closer to the top of the canvas are returned first working down to layers that are closer to the bottom of the canvas last.
Looking todo it in one loop?
Loop Through Doc layers based on bounds
-
Mike Hale
Loop Through Doc layers based on bounds
Something like this?
Code: Select allvar doc = app.activeDocument;
var layers = [];
for(var index=0;index<doc.artLayers.length;index++){
layers.push(doc.artLayers[index]);
}
layers.sort(customLayerSort);
function customLayerSort( a,b ){
return a.bounds[1]-b.bounds[1];
}
Code: Select allvar doc = app.activeDocument;
var layers = [];
for(var index=0;index<doc.artLayers.length;index++){
layers.push(doc.artLayers[index]);
}
layers.sort(customLayerSort);
function customLayerSort( a,b ){
return a.bounds[1]-b.bounds[1];
}