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

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

Community Beginner ,
Feb 08, 2016 Feb 08, 2016

Copy link to clipboard

Copied

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

thanks in advance

TOPICS
Actions and scripting

Views

1.3K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Beginner , Feb 09, 2016 Feb 09, 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(charIDToTy

...

Votes

Translate

Translate
Adobe
Community Expert ,
Feb 08, 2016 Feb 08, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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 ,
Feb 09, 2016 Feb 09, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Community Beginner ,
Feb 09, 2016 Feb 09, 2016

Copy link to clipboard

Copied

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;

}

Votes

Translate

Translate

Report

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 ,
Feb 09, 2016 Feb 09, 2016

Copy link to clipboard

Copied

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..

Votes

Translate

Translate

Report

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
Community Expert ,
Feb 09, 2016 Feb 09, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Community Beginner ,
Feb 09, 2016 Feb 09, 2016

Copy link to clipboard

Copied

Yes function I posted above simply returns a list of the names of the presets, so you would have to do something with them - I couple together this little sketch from a bounce of other snippets, the script allows you to filter the list of presets and select a preset from the results - It needs some more work, the search is VERY simple right now and its a modal dialog which is not so nice. the concept is interesting though, I might keep working at on this.

#target photoshop;

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;

}

function select_preset(name)

    {

    try {

        var desc = new ActionDescriptor();

        var ref = new ActionReference();

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

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

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

        ref = null;

        desc = null;

        }

    catch(e) { }

    }

picked = type_ahead ();

function type_ahead () {

    tools = getToolPresetNames();

    var w = new Window ('dialog {text: "preset selector", alignChildren: "fill"}');

    var entry = w.add ('edittext {active: true}');

    var list = w.add ('listbox', [0, 0, 150, 250], tools);

    list.selection = 0;

    entry.onChanging = function () {

                     var temp = this.text;

                     list.removeAll ();

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

                                 if (tools.toLowerCase().indexOf (temp) == 0) {

                                                        list.add ('item', tools);

                                                }

                     }

    }

    list.onChange = function () { select_preset( list.selection.text ); w.close(); }

    if (list.items.length > 0){

            list.selection = 0;

    }

    w.add ('button', undefined, 'Ok', {name: 'ok'});

    if (w.show () != 2){

    select_preset( list.selection.text )

    }

    w.close();

}

Votes

Translate

Translate

Report

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 ,
Feb 10, 2016 Feb 10, 2016

Copy link to clipboard

Copied

LATEST

very cool. It's a little easier to select a tool preset from your list than from the standard interface. Especially with hundreds of presets- all that scrolling up and down through the list just trying to find 2 or 3 common presets is a workflow killer. There's always the 'recent tool presets' list, but doesn't that get erased when you re-start Photoshop.. and, if you go through, say 15 presets or so then that list becomes overwritten from what I remember. Also, there's the preset manager where you can shuffle/re-order your most common tools to the bottom of the .tpl panel, but again that just seems like a hassle- it's not all that user-friendly.

You could always use scriptlistener to record the selecting of your tool preset, then save that script file, and assign it to a keyboard shortcut- that works. And then you can use 3rd party software (or even javascripting) to create a little on-screen button which, when clicked on,  will run that particular script file to select your tool preset. Software like AutoHotKey and PowerPro do just that.

Being able to type in the name of the preset at the top of your list and it automatically selects the preset is an excellent feature - I'll stay tuned should you continue to work on it

Votes

Translate

Translate

Report

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
Advisor ,
Feb 09, 2016 Feb 09, 2016

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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 ,
Feb 09, 2016 Feb 09, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Community Expert ,
Feb 09, 2016 Feb 09, 2016

Copy link to clipboard

Copied

That is built into Photoshop.

Capture.jpg

JJMack

Votes

Translate

Translate

Report

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