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

Toggle Tool Presets

Enthusiast ,
May 09, 2014 May 09, 2014

hi, this is a follow-up on another thread concerning toggling between a brush tool preset and an eraser tool preset. I've assembled the following script (mostly from csuebele) to try to toggle between "AIRBRUSH 1" (brush tool preset) and "Eraser Chiseled" (eraser tool preset). But it only works for the eraser tool preset when the eraser tool is active. It won't work with the brush tool preset whenever the brush tool is active, it gives an error "The command "select" is not currently available".

function getCurrentTool(){

       var ref = new ActionReference();

           ref.putEnumerated( charIDToTypeID( "capp" ),

charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );

        var desc1 = executeActionGet(ref);

       desc1 = desc1.getList(stringIDToTypeID("tool"));

         desc1 = desc1.getEnumerationType(0);

         desc1 = typeIDToStringID(desc1);

         return desc1;

    }

       if(getCurrentTool() == "brushTool"){

       

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

var idslct = charIDToTypeID( "slct" );

    var desc3267 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref1620 = new ActionReference();

        var idtoolPreset = stringIDToTypeID( "toolPreset" );

        ref1620.putName( idtoolPreset, "AIRBRUSH 1" );

    desc3267.putReference( idnull, ref1620 );

executeAction( idslct, desc3267, DialogModes.NO );

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

         

          }else{

             var idslct = charIDToTypeID( "slct" );

    var desc3276 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref1625 = new ActionReference();

        var idtoolPreset = stringIDToTypeID( "toolPreset" );

        ref1625.putName( idtoolPreset, "Eraser Chiseled" );

    desc3276.putReference( idnull, ref1625 );

executeAction( idslct, desc3276, DialogModes.NO );

          }

TOPICS
Actions and scripting
770
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
LEGEND ,
Dec 16, 2017 Dec 16, 2017

You used wrong name! Instead of "brushTool" use "paintbrushTool'. It's better to write script with notifier for this operation. Check this topic : Getting the name of the current brush preset and replace in my code 'brush' with name of a tool you choose. And of course don't forget to replace next two lines with your code, or you want to have error displayed

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
Community Expert ,
Dec 17, 2017 Dec 17, 2017
LATEST

If you want to select a tool preset by name the tool must be the current Photoshop tool or Photoshop Presets UI must be set to display all tool preset loaded that is current tool only not checked.  So your script will fail if current tool only is currently checked and the current tool is not the paint bursh or eraser tool.  You could add a change tool to eraser tool before the select preset.

JJMack
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