Could You Select All Layers Sequentially

Jan 06, 2021

Copy link to clipboard

Copied

I Wish Select All Layer One By One Sequentially. Like 1,2,3,4 so on. 

Thanks in Advance

Capture.JPG

TOPICS
Actions and scripting, How to, Make It, Problem or error

Views

170

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

Could You Select All Layers Sequentially

Jan 06, 2021

Copy link to clipboard

Copied

I Wish Select All Layer One By One Sequentially. Like 1,2,3,4 so on. 

Thanks in Advance

Capture.JPG

TOPICS
Actions and scripting, How to, Make It, Problem or error

Views

171

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
Jan 06, 2021 0
Jan 06, 2021

Copy link to clipboard

Copied

You can select multiple individual layers by holding the CTRL key and clicking each layer... ? ...

but not really sure what you mean? 🤔😮

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
Reply
Loading...
Jan 06, 2021 0
Jan 06, 2021

Copy link to clipboard

Copied

Ro Hackett It's a scripting question.

 

Kailash0D4D what should happen after Layer 1 is selected, before Layer 2 is selected?

 

There are actually two layers per "visual layer set", one being a color fill layer and one a text layer. The layer index order is not sequential. All of the fill layers come first, then the text layers (not fill then text, fill then text etc).

 

So which exact layer should be selected "sequentually"?

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
Reply
Loading...
Jan 06, 2021 0
Jan 10, 2021

Copy link to clipboard

Copied

  • In this script I want to select left to right layer sequentially. Like 1,2,3,4 etc. When fill the image in layer. The images fill in sequentially 1,2,3,4...

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
Reply
Loading...
Jan 10, 2021 0
Jan 10, 2021

Copy link to clipboard

Copied

Just in case you are attempting to create a montage template, JJMack has done a lot of work in this area which could save you developing your own script:

 

http://www.mouseprints.net/old/dpr/PhotoCollageToolkit.html

 

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
Reply
Loading...
Jan 10, 2021 0
Jan 10, 2021

Copy link to clipboard

Copied

Kailash0D4D I'm just a beginner so I may have this wrong, however, I believe that you have four methods to select a layer:

 

  1. getByName
  2. itemIndex
  3. id
  4. layers collection

 

getByName = Probably the most obvious, best if all layers have a unique name to target

itemIndex # = Number may change if layers are added or removed 

id # = Unique, static, does not change if layers are added or removed

 

It will probably depend on the template setup and how the end user will use/modify the template on what method is preferred.

 

P.S. I'm guessing that a for loop could probably cycle through all layers and and perform various steps on each layer.

 

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
Reply
Loading...
Jan 10, 2021 0
Jan 10, 2021

Copy link to clipboard

Copied

This script can be used to identify a selected layer's Name, itemIndex # or id #

 

 

/* https://community.adobe.com/t5/photoshop/could-you-select-all-layers-sequentially/m-p/11741392 */

#target photoshop

/////////// ACTIVE LAYER INSPECTOR v3 ///////////
// Displays some info about the current layer //

/* Name = Not unique */
/* itemIndex = Changes with layer addition/removal, Offset by -1 */
/* layer.id = Unique, Static */

var doc = app.activeDocument;
var docLayer = doc.activeLayer;
var layerName = docLayer.name;
var itemIndex = docLayer.itemIndex - 1;
var layerID = docLayer.id;
var typeName = docLayer.typename;
var Kind = docLayer.kind;
var bgLayer = docLayer.isBackgroundLayer;
var Parent = docLayer.parent;

alert('ACTIVE LAYER INSPECTOR' + '\r' + 'Layer Name = ' + layerName + '\r' + 'Layer Item Index # = ' + itemIndex + '\r' + 'Layer ID # = ' + layerID + '\r' + 'Layer Type = ' + typeName + '\r' + 'Layer Kind = ' + Kind + '\r' + 'Parent = ' + Parent + '\r' + 'isBackgroundLayer = ' + bgLayer);

 

 

A 1.5 minute video demo can be found here:

 

https://www.screencast.com/t/JrCHJpDe0Lq

 

Towards the end of video I delete an existing layer and replace it with the same name and position in the layer stack. Although the name and itemIndex number remain the same as the original, the id number changes to a new unique/static number.

 

EDIT 18th Jan 2021: I have added a few other informative properties to the inspector, just for fun!

 

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
Reply
Loading...
Jan 10, 2021 0
Jan 10, 2021

Copy link to clipboard

Copied

Presuming that a layer has a unique name (otherwise the first layer with the name will be targeted, which may not be the one you require):

 

 

var selectLayer1 = app.activeDocument.artLayers.getByName("Layer 1");
app.activeDocument.activeLayer = selectLayer1;

 

 

or

 

 

app.activeDocument.activeLayer = app.activeDocument.layers["Layer 1"];

 

 

 

The layers collection can also be used, it starts the indexing at zero, so the 8th layer from the top would be #7:

 

 

var selectLayer = app.activeDocument.layers[7];
app.activeDocument.activeLayer = selectLayer;

 

 

 

Selecting a single layer using the unique/static layer id value –

 

 

selectLayerById(1); // Enter layer.id number

function selectLayerById(id)
/* https://graphicdesign.stackexchange.com/questions/130739/photoshop-scripting-applying-changes-only-to-selected-artboards */
{
  var desc1 = new ActionDescriptor();
  var ref1 = new ActionReference();
  ref1.putIdentifier(charIDToTypeID('Lyr '), id);
  desc1.putReference(charIDToTypeID('null'), ref1);
  executeAction(charIDToTypeID('slct'), desc1, DialogModes.NO);
}

 

 

 

Select single layer via index value –

 

 

/* Select layer via index value, indexing starts at zero (bottom layer) */

selectLayerByIndex(8); // the 9th layer, starting from 0

function selectLayerByIndex(index) {
/* https://github.com/ES-Collection/Photoshop-Scripts/blob/master/Remove%20Unused%20Layers.jsx */
    var ref = new ActionReference();
        ref.putIndex(charIDToTypeID("Lyr "), index);
        var desc = new ActionDescriptor();
        desc.putReference(charIDToTypeID("null"), ref );
        desc.putBoolean( charIDToTypeID( "MkVs" ), false );
        executeAction(charIDToTypeID("slct"), desc, DialogModes.NO );
}

 

 

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
Reply
Loading...
Jan 10, 2021 0
Jan 15, 2021

Copy link to clipboard

Copied

Bump... So how did you go?

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
Reply
Loading...
Jan 15, 2021 0