Copy link to clipboard
Copied
How can I read out the current brush size in javascript ?
Either for the paintbrush or e.g. the clonestamp tool.
I want to read the current value and change it to a different one within a script.
...function getCurrentBrushInfo() {
var brsh = {};
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
var currentBrush = executeActionGet(ref).getObjectValue(stringIDToTypeID("currentToolOptions")).getObjectValue(charIDToTypeID('Brsh'));
brsh.diameter = currentBrush.getDouble(charIDToTypeID('Dmtr'));
brsh.hardness = currentBrush.getDouble(charIDToTypeID('Hrdn'));
brsh.angle = currentBrush.getDoubl
Copy link to clipboard
Copied
Thank-you so very much for your help!!! I did not have the script in the correct folder. I have placed it in the scripts folder and have set a custom shortcut. sorry to have explained it so poorly. It's working now : )
Copy link to clipboard
Copied
The important thing is you got it to work!
Copy link to clipboard
Copied
I wonder if anybody can help me get this script working :
How to read out current brush size in javascript
After you increase the brush size past 10px using the shortcut it jumps to 15px, I'd like to be able to keep pressing and have it only increase by 1px each time, somebody wrote a script for this but i can't get it to work. I'm affraid my knowledge is very limited when it comes to writing these scripts. In this old thread it seems that they were able to make a change to the original code they posted which fixed the script. If anybody with knowledge about photoshop scripts could help me with this that would be much appreciated!
Copy link to clipboard
Copied
Try the script mentioned here:
Copy link to clipboard
Copied
Yes! This works also for sampled brushes without them being reset to a round one
The other code c.pfaffenbichler posted, does reset the brush.
Has anyone a solution for setting the angle without the brush being reset?
TIA
Copy link to clipboard
Copied
How do you find out what the current brush type is so the tips attributes. Setting a Bristle, a Round Tip and Sample brush tips angle may require different code.
Tom may know he wrote the scriptlistener and knows how Action manager code works......
Copy link to clipboard
Copied
I need the script for a normal brush, without any fancy settings...
I thought I found it out by myself, but then I found Your reply in this thread:
Brush kind tools: spacing is always 25% by script
It works perfect.
thanks again!
Copy link to clipboard
Copied
You may want to look at this thread Is it possible to script brush opacity?
Copy link to clipboard
Copied
works perfect ! It can read out the setting for paintbrush tool as well as clonestamptool.
Copy link to clipboard
Copied
Hello,
I'm trying to adapt the provided code from above, but honestly I have no idea, what I'm doing and how it works.
I only need two functions; one that increases the brush size by 3px relatively to the current brush size set in photoshop,
and one, that decreases it by 3px.
Any help is much appreciated!
Thanks a lot!
Copy link to clipboard
Copied
setCurrentBrushSize(+3);
// or
setCurrentBrushSize(-3);
function setCurrentBrushSize(_size) {
/*
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-read-out-current-brush-size-in-javascript/td-p/8045339
*/
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(charIDToTypeID('Brsh'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
desc1.putReference(charIDToTypeID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putUnitDouble(stringIDToTypeID("masterDiameter"), charIDToTypeID('#Pxl'), _size);
desc1.putObject(charIDToTypeID('T '), charIDToTypeID('Brsh'), desc2);
executeAction(charIDToTypeID('setd'), desc1, DialogModes.NO);
}