Could You Select All Layers Sequentially

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

1.3K

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 , Jan 10, 2021 Jan 10, 2021
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.activeDocum...

Likes

Translate

Translate
Engaged ,
Jan 06, 2021 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
community guidelines
Adobe Community Professional ,
Jan 06, 2021 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
community guidelines
Explorer ,
Jan 10, 2021 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
community guidelines
Adobe Community Professional ,
Jan 10, 2021 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
community guidelines
Adobe Community Professional ,
Jan 10, 2021 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
community guidelines
Adobe Community Professional ,
Jan 10, 2021 Jan 10, 2021

Copy link to clipboard

Copied

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

 

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

 

EDIT 31st May 2021: old script removed,  new code posted below!

 

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
Adobe Community Professional ,
Jan 10, 2021 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
community guidelines
Adobe Community Professional ,
Jan 15, 2021 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
community guidelines
Explorer ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

Don't work, Please anyone help me Sequentially layer left to right.

Thanks in Advance

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
Adobe Community Professional ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

स्पष्ट कमबख्त नहीं

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
Adobe Community Professional ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

It obviously works, do you mean that you can't make it work?

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
Adobe Community Professional ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

LATEST

 

I have updated the "Active Layer Inspector" script to v1.4 (adding layer bounds):

 

ALI-14.png

 

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

#target photoshop

/////////// ACTIVE LAYER INSPECTOR v1.4 ///////////
/// Displays some info about the current layer ///

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

try {
    var savedRuler = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;

    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;

    /* https://community.adobe.com/t5/photoshop/find-out-the-size-and-position-of-an-object-in-a-layer/td-p/12057799 */
    var bounds = activeDocument.activeLayer.bounds;

    alert('ACTIVE LAYER INSPECTOR - v1.4' + '\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 + '\n' + 'Layer Bounds -' + '\r' + 'X: ' + bounds[0] + ', Y: ' + bounds[1] + '\n' + 'Width: ' + (bounds[2] - bounds[0]) + ', Height: ' + (bounds[3] - bounds[1]));
    app.preferences.rulerUnits = savedRuler;
}
catch (e) {
}

 

 

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