• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Is there way to get all layer names in current scene using Photoshop scripting?

Explorer ,
Feb 27, 2018 Feb 27, 2018

Copy link to clipboard

Copied

I have found following code to get all layer names in the current scene using Photoshop scripting.

var getLayerNames = function() {

    var ref1 = new ActionReference();

    ref1.putEnumerated(charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));

    var count = executeActionGet(ref1).getInteger(charIDToTypeID('NmbL'));

    // get all layer names

    var layerNamesSet = [];

    for (var i = count; i >= 1; i--) {

      var ref2 = new ActionReference();

      ref2.putIndex(charIDToTypeID('Lyr '), i);

      var desc = executeActionGet(ref2);  // Access layer index #i

      var layerSection = typeIDToStringID(desc.getEnumerationValue(stringIDToTypeID('layerSection')));

     

      if (layerSection == 'layerSectionStart' || layerSection == 'layerSectionEnd') { // Group start and end

        continue;

      }

      var layerName = desc.getString(stringIDToTypeID("name"));

      layerNamesSet.push(layerName);

    }

    return layerNamesSet;

  }

In above function, list of layers names is returned. But in Photoshop scripting there is a direct way to get layer comps names as in below code.

var layerComps = app.activeDocument.layerComps;

I read a lot of references for Photoshop scripting. But I couldn't find direct way to get layer names as layer comps.

I want to know, is there any way to get layer names in directly?

TOPICS
Actions and scripting

Views

1.8K

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
LEGEND ,
Feb 27, 2018 Feb 27, 2018

Copy link to clipboard

Copied

Do you want to get array of layers from layers composition? If from current one it's the same what that above function does. Perhaps you want to extract them not by that function but from layers composition? From active one or any other on a list ?

Votes

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 ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

LATEST

I want to get all layer names from the current active document.

1.PNG

In above example, I want to get below names of the array.

  • Rectangle 1
  • Rectangle 2
  • Rectangle 3
  • Rectangle 4

I can do it using above mentioned function. I want to know is there any way to get it in direct method as Layer comps.

Votes

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