Skip to main content
greless
Inspiring
April 4, 2019
Question

how do I know which layer it is by loading the selection

  • April 4, 2019
  • 2 replies
  • 936 views

Hello, everybody!

     I am here again.

     as shown in the figure,the canvas had a selection is selected,It belongs to the layer 2,A layer has been loaded into the selection,How do I know which layer it is?

ths ccript is set selection,i think There should be a way to get it

  try {

        var d = new ActionDescriptor();

        var r = new ActionReference();

        r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));

        d.putReference(stringIDToTypeID("null"), r);

        var r1 = new ActionReference();

        r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("transparencyEnum"));

        r1.putName(stringIDToTypeID("layer"), "Layer 2");

        d.putReference(stringIDToTypeID("to"), r1);

        executeAction(stringIDToTypeID("set"), d, DialogModes.NO);

        }

    catch (e) { if (e.number!=8007) { alert("Line: "+e.line+"\n\n"+e,"Bug!",true); throw(e); } }

This topic has been closed for replies.

2 replies

c.pfaffenbichler
Community Expert
Community Expert
April 4, 2019

A Selection has no direct connection to a specific Layer, so whether an active Selection is the same as a Layer’s transparency would probably necessitate a somewhat convoluted workaround (like using Edit > Calculations to store the existing Selection and the Layer’s transparency in a new file or channel using the Blend Mode »Difference« and evaluating the resulting Histogram).

What is the point of this anyway?

greless
grelessAuthor
Inspiring
April 4, 2019

The problem can be described as how to determine whether a selection of layer  is selected or not?

Legend
April 4, 2019

You can compare the selection boundaries and the boundaries of the layers.

c.pfaffenbichler
Community Expert
Community Expert
April 4, 2019

But the bounds would only be reliable for this if the Selection and the Layer’s transparency are rectangular, I guess.