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

How to read out current brush size in javascript

Community Beginner ,
Feb 02, 2016 Feb 02, 2016

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.

TOPICS
Actions and scripting

Views

5.5K

Translate

Translate

Report

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

correct answers 1 Correct answer

Participant , Feb 03, 2016 Feb 03, 2016

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

...

Votes

Translate

Translate
Adobe
New Here ,
Jun 23, 2021 Jun 23, 2021

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 : )

Votes

Translate

Translate

Report

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 ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

The important thing is you got it to work! 

Votes

Translate

Translate

Report

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
New Here ,
Jun 23, 2021 Jun 23, 2021

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!

Votes

Translate

Translate

Report

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 ,
Nov 11, 2022 Nov 11, 2022

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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
Explorer ,
Jun 28, 2016 Jun 28, 2016

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

Votes

Translate

Translate

Report

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 ,
Sep 23, 2016 Sep 23, 2016

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......

Capture.jpg

JJMack

Votes

Translate

Translate

Report

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
New Here ,
Sep 24, 2016 Sep 24, 2016

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!

Votes

Translate

Translate

Report

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 ,
Sep 24, 2016 Sep 24, 2016

Copy link to clipboard

Copied

You may want to look at this thread Is it possible to script brush opacity?

JJMack

Votes

Translate

Translate

Report

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 Beginner ,
Feb 03, 2016 Feb 03, 2016

Copy link to clipboard

Copied

works perfect ! It can read out the setting for paintbrush tool as well as clonestamptool.

Votes

Translate

Translate

Report

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
New Here ,
Sep 23, 2016 Sep 23, 2016

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!

Votes

Translate

Translate

Report

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 ,
Nov 11, 2022 Nov 11, 2022

Copy link to clipboard

Copied

LATEST

@visualkraut 

 

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);
}

Votes

Translate

Translate

Report

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