2 Replies Latest reply on May 22, 2014 2:55 PM by skeddles

    Photoshop opens dialog box when trying to fill a layer with transparent pixels locked

    skeddles

      This script should set the layer to lock transparent pixels, and then fill the layer with a color. It does that, except when it gets to the fill stage, it opens the fill dialog box, and you have to hit okay.

      If you omit the transparent pixel line, it runs as expected, no dialog box.

      Is there a way to suppress the box? Or am I doing something wrong that's causing the box to open?

       

      #target photoshop
      app.bringToFront();
      
      doc = app.activeDocument;
      doc.artLayers[0].isBackgroundLayer = false;
      doc.artLayers[0].transparentPixelsLocked = true;
      app.activeDocument.selection.fill(app.foregroundColor); 
      
        • 1. Re: Photoshop opens dialog box when trying to fill a layer with transparent pixels locked
          c.pfaffenbichler Level 9

          Not sure why that happens.

          But I would recommend foregoing the locking and using the AM code for a Fill that honours the transparency.

          #target photoshop 

          app.bringToFront(); 

           

          doc = app.activeDocument; 

          doc.artLayers[0].isBackgroundLayer = false; 

          doc.activeLayer = doc.artLayers[0];

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

          var idFl = charIDToTypeID( "Fl  " );

              var desc18 = new ActionDescriptor();

              var idUsng = charIDToTypeID( "Usng" );

              var idFlCn = charIDToTypeID( "FlCn" );

              var idFrgC = charIDToTypeID( "FrgC" );

              desc18.putEnumerated( idUsng, idFlCn, idFrgC );

              var idOpct = charIDToTypeID( "Opct" );

              var idPrc = charIDToTypeID( "#Prc" );

              desc18.putUnitDouble( idOpct, idPrc, 100.000000 );

              var idMd = charIDToTypeID( "Md  " );

              var idBlnM = charIDToTypeID( "BlnM" );

              var idNrml = charIDToTypeID( "Nrml" );

              desc18.putEnumerated( idMd, idBlnM, idNrml );

              var idPrsT = charIDToTypeID( "PrsT" );

              desc18.putBoolean( idPrsT, true );

          executeAction( idFl, desc18, DialogModes.NO );

          • 2. Re: Photoshop opens dialog box when trying to fill a layer with transparent pixels locked
            skeddles Level 1

            I don't understand what's happening, but that definitely did the trick!