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

Array of selected layers - how to get it

Community Beginner ,
Apr 04, 2012 Apr 04, 2012

Copy link to clipboard

Copied

Hello Everybody

I'm looking for a way to get all the selected layers as array.

With app.activeDocument.activeLayer i can select only the top-most of the selected layers.

There is a way to achieve this in ExtendScript:

function getSelectedLayers() {

   var layerArray = new Array;

      var desc = new ActionDescriptor();

         var ref = new ActionReference();

         ref.putClass( stringIDToTypeID('layerSection') );

      desc.putReference( charIDToTypeID('null'), ref );

         var layerRef = new ActionReference();

         layerRef.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

      desc.putReference( charIDToTypeID('From'), layerRef );

      executeAction( charIDToTypeID('Mk  '), desc, DialogModes.NO );

   var tempLayerSet = app.activeDocument.activeLayer.layers;

   for ( var layerIndex = 0; layerIndex < tempLayerSet.length; layerIndex++ ) {

      layerArray.push( tempLayerSet[layerIndex] );

   }

   executeAction( charIDToTypeID('undo'), undefined, DialogModes.NO );

   return layerArray;

};

How can i do that using Photoshop SDK?

Thanks in advance.

TOPICS
SDK

Views

2.7K

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
Adobe Employee ,
Apr 05, 2012 Apr 05, 2012

Copy link to clipboard

Copied

The JavaScript to C++ conversion is not too difficult. Check out the automation examples. There are suites that you need to acquire for ActionDescriptor(s) and ActionControls(s) and the conversion is almost line by line. Install the Listener plug-in from the SDK and it will generate code just like ScriptListener does for JavaScript. You can use that for a reference.

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
Community Beginner ,
Apr 05, 2012 Apr 05, 2012

Copy link to clipboard

Copied

Thanks for an answer!

So i've to use C++? Can't it be done with as3 / javascript?

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
Community Beginner ,
Apr 06, 2012 Apr 06, 2012

Copy link to clipboard

Copied

LATEST

Please someone help me with that.

Why in extendscript theres a document.activeLayer.layers property, and in sdk there isn't?

Is there a way of passing Array of Layer objects from jsx to as? I managed to get an array of strings, but how to do the same with Layer() ?

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