Sort Layer select

Explorer ,
May 05, 2021 May 05, 2021

Copy link to clipboard

Copied

I have 5 layers. In this scripts First 5 Layer,4Layers,3Layers,2Layers,1Layers, But i want 1Layer,2Layers,3Layers,4Layers,5Layers etc. Please Accendring ther layer

 

var newName =("layer name", "Layer");

var docRef = app.activeDocument;

var layers = getSelectedLayers(app.activeDocument);
for (var i = 0; i <layers.length; i ++){
layers[i].selected = true;
docRef.activeLayer = layers[i];
alert(docRef.activeLayer.name);
}

function getSelectedLayers(){
var idGrp = stringIDToTypeID( "groupLayersEvent" );
var descGrp = new ActionDescriptor();
var refGrp = new ActionReference();
refGrp.putEnumerated(charIDToTypeID( "Lyr " ),charIDToTypeID( "Ordn" ),charIDToTypeID( "Trgt" ));
descGrp.putReference(charIDToTypeID( "null" ), refGrp );
executeAction( idGrp, descGrp, DialogModes.ALL );
var resultLayers=new Array();
for (var ix=0;ix<app.activeDocument.activeLayer.layers.length;ix++){resultLayers.push(app.activeDocument.activeLayer.layers[ix])}
var id8 = charIDToTypeID( "slct" );
var desc5 = new ActionDescriptor();
var id9 = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var id10 = charIDToTypeID( "HstS" );
var id11 = charIDToTypeID( "Ordn" );
var id12 = charIDToTypeID( "Prvs" );
ref2.putEnumerated( id10, id11, id12 );
desc5.putReference( id9, ref2 );
executeAction( id8, desc5, DialogModes.NO );
return resultLayers;
}

TOPICS
Actions and scripting, Bug, Feature request, How to, Import and export, Make It, Problem or error

Views

934

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , May 05, 2021 May 05, 2021
Can be used layers.reverse(); or you can change the order of this loop for (var ix = app.activeDocument.activeLayer.layers.length-1; ix >= 0; ix--) or this for (var i = layers.length-1; i >= 0; i--) choose...

Likes

Translate

Translate
Adobe Community Professional ,
May 05, 2021 May 05, 2021

Copy link to clipboard

Copied

Can be used

layers.reverse();

 

or you can change the order of this loop

for (var ix = app.activeDocument.activeLayer.layers.length-1; ix >= 0; ix--)

 

or this

for (var i = layers.length-1; i >= 0; i--)

 

choose...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 05, 2021 May 05, 2021

Copy link to clipboard

Copied

LATEST

Thanks r-bin, Thanku so much you are great. I glad to you

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines