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

Is it possible to get layer, layerset and layer with in layerset status...!!!

Engaged ,
Oct 15, 2015 Oct 15, 2015

Copy link to clipboard

Copied

Hi Everyone!,

Is it possible to get layer, layerset and layer with in layerset status. Since I have faced big problem beyond this.

I have an one PS document which is contain collection of layer, collection layersets with layer. I need apply function for each layer and layersets and all layers with in layerset.

Also I tried one code but its getting error. Please help me to out this code...

-yajiv

#target photoshop

app.bringToFront();

$.level=2;

var docRef = app.activeDocument;

var log="";

var x=0;

var n=Number(docRef.layers.length)-1;

for (i=0;i<n;i++){

    var tm=String(docRef.layers);

    var isLayer=tm.lastIndexOf("ArtLayer");

    var isLayerSet=tm.lastIndexOf("LayerSet");

    if(isLayer!=-1){

        Check_LayerStructure(docRef.layers,"Layer");

    }

    if(isLayerSet!=-1){

        Check_LayerStructure(docRef.layerSets,"LayerSets");

        x=x+1;

        }

}

function Check_LayerStructure(objLayer,objflag,x){       \  

    if(objflag=="Layer"){

        LayetStructure(objLayer,objLayer.name,BlendMode.NORMAL,100,100,0,true," Layer ");

        }

    else if(objflag=="LayerSets"){

        LayetStructure(objLayer,objLayer.name,BlendMode.PASSTHROUGH,100,100,1,true," Set ");

        m=Number(objLayer.layers.length)

      

        for (j=0;j<m;j++){

            var tm=String(objLayer.layers);

            var isLayer=tm.lastIndexOf("ArtLayer");

            var isLayerSet=tm.lastIndexOf("LayerSet");

            if(isLayer!=-1){

                Check_LayerStructure(objLayer.layers,"Layer");

            }

            if(isLayerSet!=-1){

                Check_LayerStructure(objLayer.layerSets,"LayerSets",x);

                }

    } // Layerset Loop

}// I For Loop

}//Function loop

function LayetStructure(layerRef,L,bMode,Opt,fillOpt,S,layVisible,Lref){

    if(layerRef.blendMode!=bMode){

          if (confirm (L + Lref+"belend mode was wrong...!!!\n"+"Do you want to change....?")){

              layerRef.blendMode=bMode;

              log=log+"- " +L+ Lref+ "belend mode was changed...!!!\n\n";

              e=1;

            }      

        }

   if(layerRef.opacity!=Opt) {

          if (confirm (L + Lref+ "Opacity was "+Math.round(layerRef.opacity)+"%...!!!\n"+"Do you want to change....?")){

              layerRef.opacity=Opt;

             log=log+"- " + L + Lref+ "Opacity was changed to 100...!!!\n\n";

              e=1;

            }      

       }

 

      if(layerRef.fillOpacity!=fillOpt && S==0) {

          if (confirm (L + Lref+ "Fill was "+Math.round(layerRef.fillOpacity)+"%...!!!\n"+"Do you want to change....?")){

              layerRef.fillOpacity=fillOpt;

              log=log+"- " + L + Lref+ "Fill was changed to 100...!!!\n\n";

              e=1;

            }      

       }

 

    if(layerRef.visible!=layVisible) {

          if (L + Lref+ "eye was off..!!!\n"+"Do you want to change....?"){

              layerRef.visible=layVisible;

              log=log+"- " + L + Lref+ "eye was turn into on...!!!\n\n";

              e=1;

            }      

       }

  }

TOPICS
Actions and scripting

Views

629

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

Community Expert , Oct 17, 2015 Oct 17, 2015

Action Manager code would naturally be faster, but if you should be more comfortable with DOM code this might be of use to you.

#target photoshop

var theLayers = collectLayers(app.activeDocument, []);

alert (theLayers.join("\n"));

////// function collect all layers //////

function collectLayers (theParent, allLayers) {

  if (!allLayers) {var allLayers = new Array}

  else {};

  var theNumber = theParent.layers.length - 1;

  for (var m = theNumber; m >= 0;m--) {

  var theLayer = theParent.layers

...

Votes

Translate

Translate
Adobe
Community Expert ,
Oct 16, 2015 Oct 16, 2015

Copy link to clipboard

Copied

What exactly do you need to get?

Please provide a screenshot of the Layers Panel and a text representing the information you want to get for those Layers/LayerSets …

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
Engaged ,
Oct 16, 2015 Oct 16, 2015

Copy link to clipboard

Copied

Hi c.pfaffenbichler,

Thanks for your reply. What I need exactly mentioned below.

1. I need to check Layer property whether layer has 100% opacity and blend mode Normal

2. As well as check layerset property whether layerset has 100% fillopacity and blend mode is PASS THROUGH

3. In Photoshop document has many layer and layerset. As well as the layerset has many layer and layerset.

4. I need create recursive function to check all layers and layerset....

Thanks in advance.

-- yajiv

Screen Shot 2015-10-17 at 10.30.18 AM.png

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 Expert ,
Oct 17, 2015 Oct 17, 2015

Copy link to clipboard

Copied

Action Manager code would naturally be faster, but if you should be more comfortable with DOM code this might be of use to you.

#target photoshop

var theLayers = collectLayers(app.activeDocument, []);

alert (theLayers.join("\n"));

////// function collect all layers //////

function collectLayers (theParent, allLayers) {

  if (!allLayers) {var allLayers = new Array}

  else {};

  var theNumber = theParent.layers.length - 1;

  for (var m = theNumber; m >= 0;m--) {

  var theLayer = theParent.layers;

// apply the function to layersets;

  if (theLayer.typename == "ArtLayer") {

  allLayers.push([theLayer, theLayer.blendMode, theLayer.opacity, theLayer.fillOpacity])

  }

  else {

  allLayers = (collectLayers(theLayer, allLayers))

// this line includes the layer groups;

  allLayers.push([theLayer, theLayer.blendMode, theLayer.opacity, theLayer.fillOpacity]);

  }

  };

  return allLayers

  };

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
Engaged ,
Oct 17, 2015 Oct 17, 2015

Copy link to clipboard

Copied

Hi c.pfaffenbichler!


Kudos and thank you for your marvelous support. You are too good and i did not think about that side.


This what I needed. Your are much appreciated.

-- yajiv

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 Expert ,
Oct 17, 2015 Oct 17, 2015

Copy link to clipboard

Copied

LATEST

Should the Script take too long to be useful an Action Manager alternative would be possible..

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