Search code examples
javascriptinglayerboundsphotoshop-script

Photoshop script - How to toggles between 2 linked layer groups


I am a Photoshop beginner and currently use version Photoshop CC2015.

However, one command I feel Photoshop must have is to create function to toggles between 2 linked layers

I have to switch manually which I feel can be automated using scripting which are difficult for me being a beginner.

Can anybody help me in this regard.

Thanks very much! Let me donate a little bit of money to anyone who can do it

enter image description here

enter image description here

enter image description here


Solution

  • If you need to switch between two layers, it's super easy:

    var layer = activeDocument.activeLayer;
    var linkedLayers = layer.linkedLayers;
    if (linkedLayers.length > 0) {
      activeDocument.activeLayer = linkedLayers[0];
    }
    

    enter image description here

    cycling through 2+ however would require a different approach.