3 Replies Latest reply on Jul 9, 2017 12:27 PM by j.krueger

    Find channel by name and fill

    j.krueger Level 1

      I was looking for another pretty basic channel script. Thanks to those who have helped so far, it is much appreciated.

      The script would look at the channels in the current Photoshop file, if channel name "PLACEHOLDER" is present,

      it would fill that entire channel with black, else it does nothing.

        • 1. Re: Find channel by name and fill
          c.pfaffenbichler Level 9

          // 2017, use it at your ow risk;

          #target photoshop

          if (app.documents.length > 0) {

          var myDocument = app.activeDocument;

          for (var m = 0; m < myDocument.channels.length; m++) {

          var thisChannel = myDocument.channels[m];

          if (thisChannel.name == "PLACEHOLDER") {

          myDocument.selection.deselect();

          myDocument.activeChannels = [thisChannel];

          // =======================================================

          var desc4 = new ActionDescriptor();

          desc4.putEnumerated( charIDToTypeID( "Usng" ), charIDToTypeID( "FlCn" ), charIDToTypeID( "Blck" ) );

          desc4.putUnitDouble( charIDToTypeID( "Opct" ), charIDToTypeID( "#Prc" ), 100.000000 );

          desc4.putEnumerated( charIDToTypeID( "Md  " ), charIDToTypeID( "BlnM" ), charIDToTypeID( "Nrml" ) );

          executeAction( charIDToTypeID( "Fl  " ), desc4, DialogModes.NO );

          }

          }

          };

          • 2. Re: Find channel by name and fill
            c.pfaffenbichler Level 9

            If the Channels are particularly numerous identifying the Channels by DOM code may be noticeably slower than utilising AM code, though.

            • 3. Re: Find channel by name and fill
              j.krueger Level 1

              Thanks,

              Typical scenarios would have 5-12 channels. On my machine a 10 channel doc completes in ~4sec, which seems reasonable.