Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to create "ALL" preferences of spotHealingBrushTool?

Enthusiast ,
Aug 20, 2013 Aug 20, 2013

When I select spotHealingBrushTool in an action I can only put the brush diameter, etc, but not the

Mode:Normal

Type: Content-Aware

Sample All Layers: true

ScriptListener does not detect it.

Anyone has done this?

selectTool('spotHealingBrushTool');

// Missing:

// Mode:Normal

// Type: Content-Aware

// Sample All Layers: true

var idsetd = charIDToTypeID( "setd" );

    var desc51 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref16 = new ActionReference();

        var idBrsh = charIDToTypeID( "Brsh" );

        var idOrdn = charIDToTypeID( "Ordn" );

        var idTrgt = charIDToTypeID( "Trgt" );

        ref16.putEnumerated( idBrsh, idOrdn, idTrgt );

    desc51.putReference( idnull, ref16 );

    var idT = charIDToTypeID( "T   " );

        var desc52 = new ActionDescriptor();

        var idDmtr = charIDToTypeID( "Dmtr" );

        var idPxl = charIDToTypeID( "#Pxl" );

        desc52.putUnitDouble( idDmtr, idPxl, 40.000000 );

        var idHrdn = charIDToTypeID( "Hrdn" );

        var idPrc = charIDToTypeID( "#Prc" );

        desc52.putUnitDouble( idHrdn, idPrc, 50.000000 );

        var idAngl = charIDToTypeID( "Angl" );

        var idAng = charIDToTypeID( "#Ang" );

        desc52.putUnitDouble( idAngl, idAng, 0.000000 );

        var idRndn = charIDToTypeID( "Rndn" );

        var idPrc = charIDToTypeID( "#Prc" );

        desc52.putUnitDouble( idRndn, idPrc, 100.000000 );

        var idSpcn = charIDToTypeID( "Spcn" );

        var idPrc = charIDToTypeID( "#Prc" );

        desc52.putUnitDouble( idSpcn, idPrc, 25.000000 );

        var idIntr = charIDToTypeID( "Intr" );

        desc52.putBoolean( idIntr, true );

        var idflipX = stringIDToTypeID( "flipX" );

        desc52.putBoolean( idflipX, false );

        var idflipY = stringIDToTypeID( "flipY" );

        desc52.putBoolean( idflipY, false );

    var idcomputedBrush = stringIDToTypeID( "computedBrush" );

    desc51.putObject( idT, idcomputedBrush, desc52 );

executeAction( idsetd, desc51, DialogModes.NO );

//////////////////////////////////

function selectTool(tool) {

    var desc9 = new ActionDescriptor();

        var ref7 = new ActionReference();

        ref7.putClass( app.stringIDToTypeID(tool) );

    desc9.putReference( app.charIDToTypeID('null'), ref7 );

    executeAction( app.charIDToTypeID('slct'), desc9, DialogModes.NO );

};

TOPICS
Actions and scripting
812
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Guru ,
Aug 20, 2013 Aug 20, 2013

I would be happy if someone else knows how to do this but the only way I know to set all the tool option via a script is by using tool presets.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 20, 2013 Aug 20, 2013

Yes, I just notice that saving a preset will save that properties as well.

But where is it?

I need to transfer that preset to the same location on other computers.

I can't find it on CS6, windows7.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Aug 20, 2013 Aug 20, 2013

Some notes before the code. I think the easiest way to work with presets is by name and embedded the preset in the script. But the preset names need to be unique. If the user already has a tool preset with the same name this script will use the first name match if finds.

File.prototype.writeByte = function(b) {

  this.write(String.fromCharCode(b));

};

function loadPreset(file){

    var desc = new ActionDescriptor();

    var ref = new ActionReference();

    ref.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID( "toolPreset" ) );

    ref.putEnumerated( charIDToTypeID( "capp" ),charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ));

    desc.putReference( charIDToTypeID( "null" ), ref );

    desc.putPath( charIDToTypeID( "T   " ), new File( file ) );

    desc.putBoolean( charIDToTypeID( "Appe" ), true );

    executeAction(charIDToTypeID( "setd" ), desc, DialogModes.NO );

};

function selectTool(tool) {

    var desc = new ActionDescriptor();

        var ref = new ActionReference();

        ref.putClass( app.stringIDToTypeID(tool) );

    desc.putReference( app.charIDToTypeID('null'), ref );

    executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO );

};

function selectPreset(presetName){

    var desc = new ActionDescriptor();

    var ref = new ActionReference();

    ref.putName( stringIDToTypeID( "toolPreset" ), presetName );

    desc.putReference( charIDToTypeID( "null" ), ref );

    executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );

};

var kSpotHealingBrush = 'spotHealingBrushTool';

// tool preset names should be unique. This example only uses one preset

// but the embedded preset could have as many presets as you need.

var toolPresetName = 'Spot Healing Brush Tool Hard Round 19 1';

selectTool(kSpotHealingBrush);

try{

    selectPreset(toolPresetName);// if a preset with that name already exists use it

}catch(e){// else load the preset(s) and try again

    // optional - create new preset file from embedded data and load. Delete all lines in catch if not  using fallback

    // data from a .tpl file. This data is for one preset but it could contain as many as you need

    var toolPresetBinaryArray = [56,66,84,80,0,0,0,3,0,0,0,1,56,66,73,77,116,112,116,112,0,0,4,124,0,0,0,1,0,0,0,40,0,83,0,112,0,111,0,116,0,32,0,72,0,101,0,97,0,108,0,105,0,110,0,103,0,32,0,66,0,114,0,117,0,115,0,104,0,32,0,84,0,111,0,111,0,108,0,32,0,72,0,97,0,114,0,100,0,32,0,82,0,111,0,117,0,110,0,100,0,32,0,49,0,57,0,32,0,49,0,0,0,0,0,16,0,0,0,1,0,0,0,0,0,20,115,112,111,116,72,101,97,108,105,110,103,66,114,117,115,104,84,111,111,108,0,0,0,25,0,0,0,4,102,108,111,119,108,111,110,103,0,0,0,100,0,0,0,0,77,100,32,32,101,110,117,109,0,0,0,0,66,108,110,77,0,0,0,0,78,114,109,108,0,0,0,0,79,112,99,116,108,111,110,103,0,0,0,100,0,0,0,0,66,114,115,104,79,98,106,99,0,0,0,1,0,0,0,0,0,13,99,111,109,112,117,116,101,100,66,114,117,115,104,0,0,0,8,0,0,0,0,68,109,116,114,85,110,116,70,35,80,120,108,64,51,0,0,0,0,0,0,0,0,0,0,72,114,100,110,85,110,116,70,35,80,114,99,64,89,0,0,0,0,0,0,0,0,0,0,65,110,103,108,85,110,116,70,35,65,110,103,0,0,0,0,0,0,0,0,0,0,0,0,82,110,100,110,85,110,116,70,35,80,114,99,64,89,0,0,0,0,0,0,0,0,0,0,83,112,99,110,85,110,116,70,35,80,114,99,64,57,0,0,0,0,0,0,0,0,0,0,73,110,116,114,98,111,111,108,1,0,0,0,5,102,108,105,112,88,98,111,111,108,0,0,0,0,5,102,108,105,112,89,98,111,111,108,0,0,0,0,14,117,115,101,84,105,112,68,121,110,97,109,105,99,115,98,111,111,108,1,0,0,0,5,102,108,105,112,88,98,111,111,108,0,0,0,0,5,102,108,105,112,89,98,111,111,108,0,0,0,0,15,98,114,117,115,104,80,114,111,106,101,99,116,105,111,110,98,111,111,108,0,0,0,0,15,109,105,110,105,109,117,109,68,105,97,109,101,116,101,114,85,110,116,70,35,80,114,99,0,0,0,0,0,0,0,0,0,0,0,16,109,105,110,105,109,117,109,82,111,117,110,100,110,101,115,115,85,110,116,70,35,80,114,99,64,57,0,0,0,0,0,0,0,0,0,9,116,105,108,116,83,99,97,108,101,85,110,116,70,35,80,114,99,64,105,0,0,0,0,0,0,0,0,0,0,115,122,86,114,79,98,106,99,0,0,0,1,0,0,0,0,0,0,98,114,86,114,0,0,0,4,0,0,0,0,98,86,84,121,108,111,110,103,0,0,0,2,0,0,0,0,102,83,116,112,108,111,110,103,0,0,0,25,0,0,0,6,106,105,116,116,101,114,85,110,116,70,35,80,114,99,0,0,0,0,0,0,0,0,0,0,0,0,77,110,109,32,85,110,116,70,35,80,114,99,0,0,0,0,0,0,0,0,0,0,0,13,97,110,103,108,101,68,121,110,97,109,105,99,115,79,98,106,99,0,0,0,1,0,0,0,0,0,0,98,114,86,114,0,0,0,4,0,0,0,0,98,86,84,121,108,111,110,103,0,0,0,0,0,0,0,0,102,83,116,112,108,111,110,103,0,0,0,25,0,0,0,6,106,105,116,116,101,114,85,110,116,70,35,80,114,99,0,0,0,0,0,0,0,0,0,0,0,0,77,110,109,32,85,110,116,70,35,80,114,99,0,0,0,0,0,0,0,0,0,0,0,17,114,111,117,110,100,110,101,115,115,68,121,110,97,109,105,99,115,79,98,106,99,0,0,0,1,0,0,0,0,0,0,98,114,86,114,0,0,0,4,0,0,0,0,98,86,84,121,108,111,110,103,0,0,0,0,0,0,0,0,102,83,116,112,108,111,110,103,0,0,0,25,0,0,0,6,106,105,116,116,101,114,85,110,116,70,35,80,114,99,0,0,0,0,0,0,0,0,0,0,0,0,77,110,109,32,85,110,116,70,35,80,114,99,0,0,0,0,0,0,0,0,0,0,0,12,117,115,101,66,114,117,115,104,80,111,115,101,98,111,111,108,0,0,0,0,24,117,115,101,80,114,101,115,115,117,114,101,79,118,101,114,114,105,100,101,115,83,105,122,101,98,111,111,108,0,0,0,0,27,117,115,101,80,114,101,115,115,117,114,101,79,118,101,114,114,105,100,101,115,79,112,97,99,105,116,121,98,111,111,108,0,0,0,0,9,117,115,101,76,101,103,97,99,121,98,111,111,108,0,0,0,0,0,83,116,109,83,98,111,111,108,0,0,0,0,0,83,116,109,66,98,111,111,108,0,0,0,0,0,83,116,109,73,98,111,111,108,0,0,0,0,0,83,116,109,65,98,111,111,108,0,0,0,0,0,73,109,112,115,98,111,111,108,0,0,0,0,0,83,109,112,83,101,110,117,109,0,0,0,0,83,109,112,84,0,0,0,0,83,114,99,78,0,0,0,0,83,109,109,83,101,110,117,109,0,0,0,0,83,109,109,84,0,0,0,0,67,110,116,87];

    var tempPresetFile = new File(Folder.temp+'/spotHealingBrushPreset.tpl');

    tempPresetFile.encoding = 'BINARY';

    tempPresetFile.open("w");

    tempPresetFile.seek(0, 0);

    for(i=0;i<toolPresetBinaryArray.length;i++){

        tempPresetFile.writeByte(toolPresetBinaryArray);

    }

    tempPresetFile.close();

    loadPreset(tempPresetFile);

    selectPreset(toolPresetName);// should work now the preset is loaded

}

To get the data from the .tpl file you need to create a preset with a unique name. In the Preset Manager you select the preset(s) and save a new set. Then run this script in ESTK. The needed data will be in the console. Copy and paste into the main script replacing the data in the toolPresetBinaryArray array. Note this only needs to be done once to get the data. Once you have the data it is no longer needed by the main script.

File.prototype.readByte = function() {

  return this.read(1).charCodeAt(0);

};

// run in ExtendScript Toolkit

// replace this file reference with the path to your preset file

var file = new File("~/desktop/Untitled Tool Presets.tpl");

var tag = new Array

file.open("r");

file.encoding = 'BINARY';

file.seek(0, 0);

for(i=0;i<file.length;i++){

tag.push(file.readByte());

}

$.writeln(tag);

file.close();

By embedding the preset you don't have to worry about distributing and installing the .tpl file with your script.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 20, 2013 Aug 20, 2013
LATEST

Hi Michael

I really apreciate your scripts and they will be helpful to many people, but I did manage to built something that should detect+delete+load every preset tools that I update for the team.

Doing this I'll be sure that every team member have the same updated preset tools and it is more pratical then go to every PC to update (I use a centralized photoshop startup script to 15 computers).

So this is working:

// detects all preset tools names and return how many

var presetNames = [];

var lengthTools = toolPresetNames();

// then erase every one on that list:

for (var a = 1 ; a<= lengthTools ; a++) {

    deleteToolPreset(1);

}

// first make a path to the folde where the brushes are stored

// the user data folder does not need admin rights to read/write

// I just need to upload a new .tpl file anytime i need:

var newPresetsFolder =  Folder("c:/Users/Public/myCompany");

// each public folder of each PC is mirroed from the central scripts on my network

// only if the files are newer then the ones on public folder

if (!newPresetsFolder.exists) newPresetsFolder.create();

//

var USER_TOOLPRESETS_FOLDER =  new Folder( newPresetsFolder +"/Tools" );

//

if (USER_TOOLPRESETS_FOLDER.exists) {

    var toolPresets = USER_TOOLPRESETS_FOLDER.getFiles('*.tpl');

    app.load( toolPresets[0] );

}

/////////////////////

function toolPresetNames() {

   var ref = new ActionReference();

   ref.putEnumerated(charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));

   var desc = executeActionGet(ref);

  var List = desc.getList(stringIDToTypeID('presetManager'));

  var list = List.getObjectValue(7).getList(charIDToTypeID('Nm  ')); // 7 = Tools

  for (var i = 0; i < list.count; i++) {

    presetNames.push(list.getString(i));

  }

  return presetNames.length;

}

////////////////////

function deleteToolPreset(index) {

    var idDlt = charIDToTypeID( "Dlt " );

    var desc3514 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

    var list42 = new ActionList();

    var ref679 = new ActionReference();

    var idtoolPreset = stringIDToTypeID( "toolPreset" );

    ref679.putIndex( idtoolPreset, index );

    list42.putReference( ref679 );

    desc3514.putList( idnull, list42 );

    executeAction( idDlt, desc3514, DialogModes.NO );

}


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines