Arrange layer order by bounds area?
Hi guys, as the title suggests, I'm trying to move the layer order by the their bounds area, this is where I got to right now, but getting an error. Not sure where I'm going wrong. Any suggestions & explanations is much appreciated!
var doc = app.activeDocument;
var layers = doc.artLayers;
function arrangeByArea() {
for (var i = 0; i < doc.artLayers.length; i++)
for (var y = 1; y < doc.artLayers.length -1; y++)
var layerArea1 = (layers.bounds[2] - layers.bounds[0]) * (layers.bounds[3] - layers.bounds[1]);
var layerArea2 = (layers
.bounds[2] - layers .bounds[0]) * (layers .bounds[3] - layers .bounds[1]); if (layerArea1 >= layerArea2) {
layers.move(layers
, ElementPlacement.PLACEAFTER);
}
}
arrangeByArea();
