2 Replies Latest reply: Dec 5, 2014 5:09 PM by Janoooo RSS

    Script and burn tool

    Janoooo Community Member

      Hello all !!

       

      How can the burn tool parameter : range, exposure, size, be place in a script ?? 

       

      Thanks.

       

      Janou.

        • 1. Re: Script and burn tool
          Pedro Cortez Marques Community Member

          range

              Values: 'burnInS' | 'burnInM' | 'burnInH'

              Get by script: True

              Set by script: False

           

          exposure (or 'opacity' in this burn tool)

              Values: 1% - 100%

              Get by script: True

              Set by script: False


          size

              Values: 1% - 1000%

              Get by script: True

              Set by script: True


          Also all this ones can be get and set by script:

          Diameter [1-500], Hardness%, Angle [-180/180], Roundness%, Spacing [0-1000], Flipy Boolean, Flipx Boolean


          The problem is exposure

          My suggestion would be to do this workarround:


          For each tool, create a group of presets like this:

          'burnInS010', 'burnInS020', 'burnInS030', 'burnInS040', 'burnInS050', 'burnInS060', 'burnInS070', 'burnInS080', 'burnInS090','burnInS100'

          where 'burnInS010' means Burn Shadows opacity 10%, etc (you could have more accuracy with more opacity values, of course)

          Then do the same for the other Ranges using

          'burnInM010', 'burnInM020',...

          'burnInH010', 'burnInH020',...

          'dodgeS010', 'dodgeS020',...

          'dodgeM010', 'dodgeM020',...

          'dodgeH010', 'dodgeH020',...


          Then by script you could pre-select the preset you want and put the other preferences by code.


          After you have ALL the presets created you can use this code:

           

          
          // Select BurnTool with all parameters
          // collected from several sources and compiled
          // If the preset doesn't exist, it gives a warning, telling how to create a new specific preset so the error doesn't comes again
          
          app.currentTool = "burnInTool";
          
          
          var Range = 'S';  // 'S' shadows | 'M' midtones | 'H' highlights
          var Exposure = 30;  // 10, 20, 30, 40, 50, 60, 70, 80, 90, 100
          selectPresetBurnDodge(Range, Exposure);
          
          
          setBrushFeatures_Burn(150, 80,undefined,undefined,undefined,undefined,undefined);
          
          
          ///////////////////////////////////////// Use Range and Exposure to choose the right Preset
          function selectPresetBurnDodge(range, exposure) {
              exposure = (exposure < 100) ? '0'+exposure.toString() : 100;
              var presetName = app.currentTool.replace(/Tool/,'') + range + exposure;
              //
              var Presets = getPresetList();
              var thisPresetExists = false;
              for(var v in Presets){
                  if (String(Presets[v]) == presetName) {
                      thisPresetExists = true;
                      break;
                  }
              }
              if (thisPresetExists) {
                  if (app.currentTool == "burnInTool" || app.currentTool == "dodgeTool") {
                      var desc = new ActionDescriptor();
                      var ref = new ActionReference();
                      ref.putName( stringIDToTypeID( "toolPreset" ), presetName );
                      desc.putReference( charIDToTypeID( "null" ), ref );
                      executeAction( charIDToTypeID( "slct" ), desc, DialogModes.ALL );
                  }
              } else {
                  alert("This Preset name '"+presetName+"' doesn't exist.\n\nCreate new " + app.currentTool + " preset.\nName:\t"+presetName+"\nRange:\t" + range+ "\nExposure:\t" + Number(exposure));
              }
          }
          ///////////////////////////////////////// Set Brush
          // Diameter [1-500], Hardness%, Angle [-180/180], Roundness%, Spacing [0-1000], Flipy Boolean, Flipx Boolean
          function setBrushFeatures_Burn (Diameter,Hardness,Angle,Roundness,Spacing,Flipy,Flipx) {
              var ref = new ActionReference();
              ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
              var appDesc = executeActionGet(ref);
              var toolDesc = appDesc.getObjectValue(stringIDToTypeID('currentToolOptions'));
              var brushDesc = toolDesc.getObjectValue(stringIDToTypeID('brush'));
              if (Diameter == undefined) Diameter = brushDesc.getDouble(stringIDToTypeID('diameter'));
              if (Hardness == undefined) Hardness = brushDesc.getDouble(stringIDToTypeID('hardness'));
              if (Angle == undefined ) Angle = brushDesc.getDouble(stringIDToTypeID('angle'));
              if (Roundness  == undefined) Roundness = brushDesc.getDouble(stringIDToTypeID('roundness'));
              if (Spacing == undefined) Spacing = brushDesc.getDouble(stringIDToTypeID('spacing'));
              if (Flipy == undefined) Flipy = brushDesc.getBoolean(stringIDToTypeID('flipY'));
              if (Flipx == undefined) Flipx = brushDesc.getBoolean(stringIDToTypeID('flipX'));
              var desc = new ActionDescriptor();
              var ref = new ActionReference();
              ref.putEnumerated( charIDToTypeID( "Brsh" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
              desc.putReference( charIDToTypeID( "null" ), ref );
              var desc1 = new ActionDescriptor();
              desc1.putDouble(stringIDToTypeID('diameter'), Diameter);
              desc1.putDouble(stringIDToTypeID('hardness'), Hardness);
              desc1.putDouble(stringIDToTypeID('angle'), Angle);
              desc1.putDouble(stringIDToTypeID('roundness'), Roundness);
              desc1.putDouble(stringIDToTypeID('spacing'), Spacing);
              desc1.putBoolean(stringIDToTypeID('flipY'), Flipy);
              desc1.putBoolean(stringIDToTypeID('flipX'), Flipx);
              desc.putObject( stringIDToTypeID('to'), charIDToTypeID( "Brsh" ), desc1 );
              executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
          }
          // get all Presets
          function getPresetList(){
              var ref = new ActionReference();
              ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
              var appDesc = executeActionGet(ref);
              var List = appDesc.getList(stringIDToTypeID('presetManager'));
              var presetNames=[];
              var list = List.getObjectValue(7).getList(charIDToTypeID('Nm  '));
              for (var i = 0; i < list.count; i++) {
                  var str = list.getString(i);
                  presetNames.push(str);
              }
              presetNames=ReturnUniqueSortedList(presetNames);
              return presetNames;
          }
          function ReturnUniqueSortedList(ArrayName) {
              var unduped = new Object;
              for (var i = 0; i < ArrayName.length; i++) {
              unduped[ArrayName[i]] = ArrayName[i];
              }
              var uniques = new Array;
              for (var k in unduped) {
                  uniques.push(unduped[k]);
              }
              return uniques.sort();
          }
          
          
          
          




          • 2. Re: Script and burn tool
            Janoooo Community Member

            Thanks