Skip to main content
Participant
July 19, 2025
Question

I want to get the current brush tool name

  • July 19, 2025
  • 2 replies
  • 159 views

I want to get the current brush tool name
I'm not referring to this method

function getTool(){  
    var ref = new ActionReference();   
    ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );   
    var cTool = typeIDToStringID(executeActionGet(ref).getEnumerationType(stringIDToTypeID('tool')));  
    return cTool;  
}

 But it is through brush attributes that we can determine whether he does not have tools or whether he has smudging or eraser tools
This is very important to me. Of course, selecting the user and then obtaining the tool can also yield what kind of tool it is, but it is not easy to use because a paintbrush without a tool will be used with the current tool, which is not suitable

Thanks for your help

2 replies

Inspiring
July 20, 2025

This code should work for "sampled" brushes (e.g., defined from a selection):

 

var ref = new ActionReference();
ref.putProperty(stringIDToTypeID('property'), stringIDToTypeID('tool'));
ref.putEnumerated(charIDToTypeID('capp'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
var toolDesc = executeActionGet(ref).getObjectValue(stringIDToTypeID('currentToolOptions'));
var brushDesc = toolDesc.getObjectValue(stringIDToTypeID('brush'));

var computedBrush = false;
if (toolDesc.getObjectType(stringIDToTypeID('brush')) == stringIDToTypeID('computedBrush')) computedBrush true;

if (computedBrush == false){
var brushName = brushDesc.getString(stringIDToTypeID('name'));
alert("Brush name: "+ brushName )
} else {
alert("Error: it's a computed brush!")
}
 
Names of the "computed" (parametrically defined) brushes seem to be unreadable.
Participant
July 20, 2025

No, this is to get the brush tip name. What I need is the tool name of the brush
It's not like selecting a brush and then searching for the tool name
But instead, it directly retrieves the type of tool the brush belongs to

Thanks for your help

Inspiring
July 21, 2025
This code should do it:
 
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("tool"));
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var applicationDesc = executeActionGet(ref);
alert(typeIDToStringID(applicationDesc.getEnumerationType(stringIDToTypeID("tool"))));
Glenn 8675309
Legend
July 19, 2025

Zero reason for a script- the program already provides the names- you have multiple choices once you click on the three dots.  I now realize your screenshots are probably from photoshop-  just click on the gear in the upper right corner of any brush set and choose show names. 

Participant
July 20, 2025

I need a script to obtain a tool for changing the type of brush
Instead of getting a name because my CEP program must support