Skip to main content
Participant
Jul 19, 2025 4:54 PM UTC
Question

I want to get the current brush tool name

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

6 replies

Inspiring
Jul 20, 2025 12:08 PM UTC

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.
Translate
Participant
Jul 20, 2025 5:26 PM UTC

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

Translate
Inspiring
Jul 21, 2025 8:00 AM UTC
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"))));
Translate
Glenn 8675309
Legend
Jul 19, 2025 5:42 PM UTC

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. 

Translate
Participant
Jul 20, 2025 7:10 AM UTC

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

Translate