Skip to main content
DavidRene
Participant
February 9, 2016
Answered

Is there a way to get a list of the tool presets in photoshop?

  • February 9, 2016
  • 4 replies
  • 1631 views

how would I go by getting a list of the tool preset that are currently load in PS?

thanks in advance

This topic has been closed for replies.
Correct answer DavidRene

I managed to figure it out, found this bit of code in a different thread and modified it to return a list of tool preset names.

function getToolPresetNames() {

    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); }

    return presetNames;

}

4 replies

Inspiring
February 9, 2016

both of your guys' scripts work - awesome. I'll look into a way to see if it helps to make it easier to select tool presets from a large list

JJMack
Community Expert
Community Expert
February 9, 2016

That is built into Photoshop.

JJMack
DavidRene
DavidReneAuthorCorrect answer
Participant
February 9, 2016

I managed to figure it out, found this bit of code in a different thread and modified it to return a list of tool preset names.

function getToolPresetNames() {

    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); }

    return presetNames;

}

Inspiring
February 9, 2016

man, this would be so useful.. but when I run the script nothing happens. What should happen when you run it? I'm using CC2014.2.2 in case it matters..

JJMack
Community Expert
Community Expert
February 9, 2016

That is a function the return a list. It must be used.  I played a little with it, to output presets list.

function getPresetNames(l) {

    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(l).getList(charIDToTypeID('Nm  '));

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

            var str = list.getString(i);

            presetNames.push(str); }

    return presetNames;

}

var PresetTypeArray = ["Brushes","Swatches","Gradients","Styles","Patterns","Contours","Custom Shapes","Tools"];

for (l=0; l<PresetTypeArray.length; l++) {

alert(PresetTypeArray + " Preset List = " + getPresetNames(l));

}

JJMack
JJMack
Community Expert
Community Expert
February 9, 2016

The idea I tried was.

I used Menu Edit>Presets>Preset Manager... then in Preset manager use Preset Type pull-down menu select tool or Ctrl+8.  Then I used use Ctrl+A to select all my current presets. Then I use the preset manager Save Set... Button and saved the set into a file on my desktop. Then I click "Done" in the Preset manager.  In the Scriptlistent log I saw this recorded. For that sequence of Photoshop steps.

 

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

var idmodalStateChanged = stringIDToTypeID( "modalStateChanged" );

    var desc15 = new ActionDescriptor();

    var idLvl = charIDToTypeID( "Lvl " );

    desc15.putInteger( idLvl, 1 );

    var idStte = charIDToTypeID( "Stte" );

    var idStte = charIDToTypeID( "Stte" );

    var identer = stringIDToTypeID( "enter" );

    desc15.putEnumerated( idStte, idStte, identer );

executeAction( idmodalStateChanged, desc15, DialogModes.NO );

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

var idsetd = charIDToTypeID( "setd" );

    var desc16 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

    desc16.putPath( idnull, new File( "C:\\Users\\John J McAssey\\Desktop\\Untitled Tool Presets.tpl" ) );

    var idT = charIDToTypeID( "T   " );

        var ref3 = new ActionReference();

        var idPrpr = charIDToTypeID( "Prpr" );

        var idtoolPreset = stringIDToTypeID( "toolPreset" );

        ref3.putProperty( idPrpr, idtoolPreset );

        var idcapp = charIDToTypeID( "capp" );

        var idOrdn = charIDToTypeID( "Ordn" );

        var idTrgt = charIDToTypeID( "Trgt" );

        ref3.putEnumerated( idcapp, idOrdn, idTrgt );

    desc16.putReference( idT, ref3 );

executeAction( idsetd, desc16, DialogModes.NO );

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

var idmodalStateChanged = stringIDToTypeID( "modalStateChanged" );

    var desc17 = new ActionDescriptor();

    var idLvl = charIDToTypeID( "Lvl " );

    desc17.putInteger( idLvl, 0 );

    var idStte = charIDToTypeID( "Stte" );

    var idStte = charIDToTypeID( "Stte" );

    var idexit = stringIDToTypeID( "exit" );

    desc17.putEnumerated( idStte, idStte, idexit );

executeAction( idmodalStateChanged, desc17, DialogModes.NO );

The saved set "C:\Users\\John J McAssey\Desktop\Untitled Tool Presets.tpl"  file is 44KB has all the presets information. However, I have no idea as how to process the data in that file.

JJMack
Inspiring
February 9, 2016

isn't that just the same as "save tool presets", unless there's some other kind of data being written to the file?

I'd like to know if there's a way to get a list as well, it could open up a few doors for allowing easier selection of tool presets, especially when you're working with hundreds of them