6 Replies Latest reply on Jan 28, 2010 1:22 PM by NotALamer

    how do i figure out what layer is being used in the script listener log?

    NotALamer Level 1

      I recorded a 'Modify Color Fill Layer' action into the ScriptingListenerJS.log file, and I can sort of understand the output, but how do I tell what layer the style is being changed for?

        • 1. Re: how do i figure out what layer is being used in the script listener log?
          Michael L Hale Level 5

          It would help to see the code, but scriptlistener can reference the layer by name, index, or enumeration( ie target ).

          • 2. Re: how do i figure out what layer is being used in the script listener log?
            NotALamer Level 1

            var idsetd = charIDToTypeID( "setd" );

             

                var desc9 = new ActionDescriptor();

             

                var idnull = charIDToTypeID( "null" );

             

                    var ref3 = new ActionReference();

             

                    var idcontentLayer = stringIDToTypeID( "contentLayer" );

             

                    var idOrdn = charIDToTypeID( "Ordn" );

             

                    var idTrgt = charIDToTypeID( "Trgt" );

             

                    ref3.putEnumerated( idcontentLayer, idOrdn, idTrgt );

             

                desc9.putReference( idnull, ref3 );

             

                var idT = charIDToTypeID( "T   " );

             

                    var desc10 = new ActionDescriptor();

             

                    var idClr = charIDToTypeID( "Clr " );

             

                        var desc11 = new ActionDescriptor();

             

                        var idRd = charIDToTypeID( "Rd  " );

             

                        desc11.putDouble( idRd, 255.000000 );

             

                        var idGrn = charIDToTypeID( "Grn " );

             

                        desc11.putDouble( idGrn, 222.630358 );

             

                        var idBl = charIDToTypeID( "Bl  " );

             

                        desc11.putDouble( idBl, 140.000007 );

             

                    var idRGBC = charIDToTypeID( "RGBC" );

             

                    desc10.putObject( idClr, idRGBC, desc11 );

             

                var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

             

                desc9.putObject( idT, idsolidColorLayer, desc10 );

             

            executeAction( idsetd, desc9, DialogModes.NO );

             

             

            I would like to be able to apply this action to an array of layers that I constructed earlier.
            • 3. Re: how do i figure out what layer is being used in the script listener log?
              Michael L Hale Level 5

              First I would clean up the scriptlistener code and turn it into a function. Then do something like this.

               

              // make your array of solidfill layers however you like
              var l1 = activeDocument.layers.getByName( 'Color Fill 1' );
              var l2 = activeDocument.layers.getByName( 'Color Fill 2' );
              var l3 = activeDocument.layers.getByName( 'Color Fill 3' );
              var layers = [ l1, l2, l3 ];
              
              // iterate the array calling the scriptlistener function
              for( l = 0;l< layers.length; l++ ){
                   setFillColorByName( layers[ l ].name );
              }
              function setFillColorByName( name ){
                  var desc = new ActionDescriptor();
                  var ref = new ActionReference();
                      ref.putName( stringIDToTypeID( "contentLayer" ), name );
                  desc.putReference( charIDToTypeID( "null" ), ref );
                      var colorDesc = new ActionDescriptor();
                          var rgbDesc = new ActionDescriptor();
                          rgbDesc.putDouble( charIDToTypeID( "Rd  " ), 255.000000 );
                          rgbDesc.putDouble( charIDToTypeID( "Grn " ), 222.630358 );
                          rgbDesc.putDouble( charIDToTypeID( "Bl  " ), 140.000007 );
                      colorDesc.putObject( charIDToTypeID( "Clr " ), charIDToTypeID( "RGBC" ), rgbDesc );
                  desc.putObject( charIDToTypeID( "T   " ), stringIDToTypeID( "solidColorLayer" ), colorDesc );
                   executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
              }
              
              • 4. Re: how do i figure out what layer is being used in the script listener log?
                NotALamer Level 1

                Awesome that worked like a charm, thanks! Is there a reference somewhere for how ActionDescriptor and ActionReference work?

                • 5. Re: how do i figure out what layer is being used in the script listener log?
                  Michael L Hale Level 5

                  No, not really. The user guide lists the properties and methods for ActionDescriptor, Action Reference, and Action List. But doesn't explain how to use them other than installing the plugin.

                  1 person found this helpful
                  • 6. Re: how do i figure out what layer is being used in the script listener log?
                    NotALamer Level 1

                    Oh well, I think I have a pretty good idea from your post, thanks again.