0 Replies Latest reply on Nov 6, 2011 6:06 AM by jugenjury

    docRef.activeLayer quirk? (CS4)

    jugenjury Level 2

      It took me awhile to figure out what was happening, but now I understand it. When running a script that selects a layer to be the active layer, it will turn visibility on for that layer if it is off. Example:

       

      I have a layer stack as follows:

       

      Layer1

      Layer2

      Layer3

      Background

       

      Layer1 is invisible. The Background layer is currently active. If I run a script that selects Layer1 using "docRef.activeLayer=Layer1Ref" it will select Layer1 and turn visibility on.

       

      My solution is to create a new function to select an active layer

       

      function LSelect(Lyr) {

          Lyrvis=Lyr.visible;

          docRef.activeLayer=Lyr;

          Lyr.visible=Lyrvis;

          return Lyr;

      }

      Usage: newActiveLayerRef=LSelect(Layer1Ref);

       

      You don't have to set a new variable to the Layer Reference for this. You can continue using the reference you sent to the function. I included that in case it isn't known which layer the script is to select as the active layer until processing conditionals.