11 Replies Latest reply: Feb 26, 2013 7:46 AM by Mattmcquiff RSS

    Applescript, create an adjustment Layer with levels

    Mattmcquiff Community Member

           I can't seam to work out how to do this I want to create a new adjustment layer with levels?

       

      How can I do this

       

      I think I am off the mark but this is all I have

       

      make new art layer with properties {kind:levels layer}

        • 1. Re: Applescript, create an adjustment Layer with levels
          Muppet Mark Community Member

          It's been a little while since I scripted PS with AppleScript ( stopped around CS2 )… but if I recall correctly layer kind write access for normal & text all the others are read only… You will probably need to do JavaScript and use ActionManager syntax to create this layer…

          • 2. Re: Applescript, create an adjustment Layer with levels
            Mattmcquiff Community Member

            Screen shot 2013-02-26 at 14.19.19.png

            This is how it looks in my actions. Was hoping to avoid Javascript for something "I think" i understand

            • 3. Re: Applescript, create an adjustment Layer with levels
              Muppet Mark Community Member

              If you have a saved action that is loaded then you can just call that…

              • 4. Re: Applescript, create an adjustment Layer with levels
                Mattmcquiff Community Member

                I was doing that I was hoping to have it as an applescript, just so I can have it all in the same place when installing it on multiple computers.

                 

                Do you know how I might be able to create that by calling javascript to create the layer?

                • 5. Re: Applescript, create an adjustment Layer with levels
                  Muppet Mark Community Member

                  Im at work where I only have CS5 and non of my old AppleScript snippets… but in answer yes it is possible… Using the scriptlistener plug-in you can record the making of a layer and save as a string inside your AppleScript… I used to a bit of this stuff before moving to Adobe's ExtendScript…

                  • 6. Re: Applescript, create an adjustment Layer with levels
                    Mattmcquiff Community Member

                    might have posted in the wrong section, I have CS5 i'll do the logging thing though!

                     

                    Thanks

                    Matt

                    • 7. Re: Applescript, create an adjustment Layer with levels
                      Mattmcquiff Community Member

                      this was the output of the listener

                       

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

                      var idslct = charIDToTypeID( "slct" );

                          var desc715 = new ActionDescriptor();

                          var idnull = charIDToTypeID( "null" );

                              var ref17 = new ActionReference();

                              var idHstS = charIDToTypeID( "HstS" );

                              var idOrdn = charIDToTypeID( "Ordn" );

                              var idPrvs = charIDToTypeID( "Prvs" );

                              ref17.putEnumerated( idHstS, idOrdn, idPrvs );

                          desc715.putReference( idnull, ref17 );

                      executeAction( idslct, desc715, DialogModes.NO );

                       

                       

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

                      var idslct = charIDToTypeID( "slct" );

                          var desc716 = new ActionDescriptor();

                          var idnull = charIDToTypeID( "null" );

                              var ref18 = new ActionReference();

                              var idHstS = charIDToTypeID( "HstS" );

                              var idOrdn = charIDToTypeID( "Ordn" );

                              var idPrvs = charIDToTypeID( "Prvs" );

                              ref18.putEnumerated( idHstS, idOrdn, idPrvs );

                          desc716.putReference( idnull, ref18 );

                      executeAction( idslct, desc716, DialogModes.NO );

                       

                       

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

                      var idslct = charIDToTypeID( "slct" );

                          var desc717 = new ActionDescriptor();

                          var idnull = charIDToTypeID( "null" );

                              var ref19 = new ActionReference();

                              var idHstS = charIDToTypeID( "HstS" );

                              var idOrdn = charIDToTypeID( "Ordn" );

                              var idPrvs = charIDToTypeID( "Prvs" );

                              ref19.putEnumerated( idHstS, idOrdn, idPrvs );

                          desc717.putReference( idnull, ref19 );

                      executeAction( idslct, desc717, DialogModes.NO );

                       

                       

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

                      var idslct = charIDToTypeID( "slct" );

                          var desc718 = new ActionDescriptor();

                          var idnull = charIDToTypeID( "null" );

                              var ref20 = new ActionReference();

                              var idHstS = charIDToTypeID( "HstS" );

                              var idOrdn = charIDToTypeID( "Ordn" );

                              var idPrvs = charIDToTypeID( "Prvs" );

                              ref20.putEnumerated( idHstS, idOrdn, idPrvs );

                          desc718.putReference( idnull, ref20 );

                      executeAction( idslct, desc718, DialogModes.NO );

                       

                       

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

                      var idslct = charIDToTypeID( "slct" );

                          var desc719 = new ActionDescriptor();

                          var idnull = charIDToTypeID( "null" );

                              var ref21 = new ActionReference();

                              var idHstS = charIDToTypeID( "HstS" );

                              var idOrdn = charIDToTypeID( "Ordn" );

                              var idPrvs = charIDToTypeID( "Prvs" );

                              ref21.putEnumerated( idHstS, idOrdn, idPrvs );

                          desc719.putReference( idnull, ref21 );

                      executeAction( idslct, desc719, DialogModes.NO );

                      • 8. Re: Applescript, create an adjustment Layer with levels
                        Muppet Mark Community Member

                        That looks like something to do with history to me…

                        • 9. Re: Applescript, create an adjustment Layer with levels
                          Mattmcquiff Community Member

                          Hopefully this is it

                           

                          var idslct = charIDToTypeID( "slct" );

                              var desc2843 = new ActionDescriptor();

                              var idnull = charIDToTypeID( "null" );

                                  var ref146 = new ActionReference();

                                  var idLyr = charIDToTypeID( "Lyr " );

                                  ref146.putName( idLyr, "Levels 1" );

                              desc2843.putReference( idnull, ref146 );

                              var idselectionModifier = stringIDToTypeID( "selectionModifier" );

                              var idselectionModifierType = stringIDToTypeID( "selectionModifierType" );

                              var idaddToSelection = stringIDToTypeID( "addToSelection" );

                              desc2843.putEnumerated( idselectionModifier, idselectionModifierType, idaddToSelection );

                              var idMkVs = charIDToTypeID( "MkVs" );

                              desc2843.putBoolean( idMkVs, false );

                          executeAction( idslct, desc2843, DialogModes.NO );

                           

                           

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

                          var idDlt = charIDToTypeID( "Dlt " );

                              var desc2844 = new ActionDescriptor();

                              var idnull = charIDToTypeID( "null" );

                                  var ref147 = new ActionReference();

                                  var idLyr = charIDToTypeID( "Lyr " );

                                  var idOrdn = charIDToTypeID( "Ordn" );

                                  var idTrgt = charIDToTypeID( "Trgt" );

                                  ref147.putEnumerated( idLyr, idOrdn, idTrgt );

                              desc2844.putReference( idnull, ref147 );

                          executeAction( idDlt, desc2844, DialogModes.NO );

                           

                           

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

                          var idMk = charIDToTypeID( "Mk  " );

                              var desc2845 = new ActionDescriptor();

                              var idnull = charIDToTypeID( "null" );

                                  var ref148 = new ActionReference();

                                  var idAdjL = charIDToTypeID( "AdjL" );

                                  ref148.putClass( idAdjL );

                              desc2845.putReference( idnull, ref148 );

                              var idUsng = charIDToTypeID( "Usng" );

                                  var desc2846 = new ActionDescriptor();

                                  var idType = charIDToTypeID( "Type" );

                                      var desc2847 = new ActionDescriptor();

                                      var idpresetKind = stringIDToTypeID( "presetKind" );

                                      var idpresetKindType = stringIDToTypeID( "presetKindType" );

                                      var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );

                                      desc2847.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );

                                  var idLvls = charIDToTypeID( "Lvls" );

                                  desc2846.putObject( idType, idLvls, desc2847 );

                              var idAdjL = charIDToTypeID( "AdjL" );

                              desc2845.putObject( idUsng, idAdjL, desc2846 );

                          executeAction( idMk, desc2845, DialogModes.NO );

                           

                           

                          It should be as simple as selecting the levels adjustment layer then selecting auto.

                           

                          Matt

                          • 10. Re: Applescript, create an adjustment Layer with levels
                            Muppet Mark Community Member

                            If thats your output the do find & replace in your text editor… find all double quotes and replace with single… JavaScript will have either as long as there proper pairs… Then wrap the whole chunk in double quotes for an AppleScript string… pass the string as argument to the app do javascript comamnd…

                            • 11. Re: Applescript, create an adjustment Layer with levels
                              Mattmcquiff Community Member

                              Oh.. thanks for explaining that one, I knew about listening but never knew what to do with it.

                              I think I'm getting there,