Copy link to clipboard
Copied
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 );
}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now