2 Replies Latest reply on Sep 6, 2015 7:20 AM by Chuck Uebele

    Script for selecting a hidden layer (while unhiding it)


      So I'll ask two versions, one for the tl;dr crowd and one for the detail-oriented folk.


      The short version:

      Is there a way to make a script that'll reveal a hidden layer and select it. For me it would be the next layer up from the currently selected layer — like photoshop's Select Forward Layer ( option+] ), except that that function skips hidden layers.


      The long version:

      I have many many files that have 4 layers each, and I'd like to align those 4 layers by hand. First I need the bottom 2 layers visible to align them, and then Layers #2 and 3, then Layers #3 and 4.


      I have the top layers set to Difference blending mode, for aligning purposes. So my workflow is this:


      1) Align two layers, by hand.

      2) Change upper layer's blending mode from Difference to Normal

      3) Make visible the next layer above

      4) Select that layer

      5) Repeat


      I know it's not much, but I'm doing this hundreds of times a session. It would be a huge time saver to automate this process.


      I don't know much about scripting though, so I'm totally in the dark on how to go about doing this. In the end, would I be able to activate the script by a hotkey?


      Thanks ahead of time for your help — hope it all works out!


        • 1. Re: Script for selecting a hidden layer (while unhiding it)
          JJMack Most Valuable Participant

          Automation can include interactive steps. However interactive steps do not belong in batch processing. 


          Also Photoshop does have an auto align layers feature. If layers have thing in common like yours seem to. Because your using difference blend mode to help you align layers.  I would think auto align layers would work well.  There should be no need to manual aligning layers..

          • 2. Re: Script for selecting a hidden layer (while unhiding it)
            Chuck Uebele Adobe Community Professional & MVP

            I do a lot of that also. Try this:


            #target photoshop
            var doc = activeDocument;
            var cLay = doc.activeLayer;
            var layNum
            var aLay = new Array()
            for(var i=0;i<doc.layers.length;i++){
                aLay[i] = doc.layers[i].name;
                if(aLay[i]==cLay.name){layNum = i}
            cLay.blendMode = BlendMode.NORMAL;
                doc.activeLayer = doc.layers[layNum-1];
                doc.activeLayer.visible = true;
                doc.activeLayer.blendMode = BlendMode.DIFFERENCE;