2 Replies Latest reply on Feb 4, 2016 10:06 AM by boo radley 2013

    Set opacity of particular layer

    boo radley 2013 Level 3

      Hi, I have a layer named 'concrete' and I'm trying to adjust its opacity to 50% in a script. Problem is, this script adjusts the active layer's opacity, not the layer named 'concrete'. So in other words the active layer might be 'Layer 12', and somewhere else in the layer stack is the layer named 'concrete'. I want to adjust its opacity to 50% without having to switch over to the 'concrete' layer, manually adjust the opacity, and then switch back to 'layer 12'. I was hoping a script could just change it automatically.  Here's what I have so far, I'm hoping someone might suggest a tweak to get it working:

       

      #target photoshop
      
      var layerRef = app.activeDocument.layers.getByName( 'concrete' );
      
      
      // =======================================================
      var idsetd = charIDToTypeID( "setd" );
          var desc9657 = new ActionDescriptor();
          var idnull = charIDToTypeID( "null" );
              var ref2889 = new ActionReference();
              var idLyr = app.activeDocument.layers.getByName( 'concrete texture' )( "Lyr " );
              var idOrdn = charIDToTypeID( "Ordn" );
              var idTrgt = charIDToTypeID( "Trgt" );
              ref2889.putEnumerated( idLyr, idOrdn, idTrgt );
          desc9657.putReference( idnull, ref2889 );
          var idT = charIDToTypeID( "T   " );
              var desc9658 = new ActionDescriptor();
              var idOpct = charIDToTypeID( "Opct" );
              var idPrc = charIDToTypeID( "#Prc" );
              desc9658.putUnitDouble( idOpct, idPrc, 50.000000 );
          var idLyr = charIDToTypeID( "Lyr " );
          desc9657.putObject( idT, idLyr, desc9658 );
      executeAction( idsetd, desc9657, DialogModes.NO );