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

Script for switching brush spacing on/off

Explorer ,
Mar 12, 2025 Mar 12, 2025

Copy link to clipboard

Copied

Hi! I found a script that switches the brush spacing in this post https://community.adobe.com/t5/photoshop-ecosystem-discussions/q-brush-s-spacing-setting-for-get-set...

But when it switches, it resets the brush to the default settings. Is it possible to switch without resetting the brush? Here is this script by r-bin

 

function get_brush_space_checkbox()

    {

    try

        {

        var r = new ActionReference();

        r.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID( "tool" ) );

        r.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

        var ret = executeActionGet(r);

        ret = ret.getObjectValue(stringIDToTypeID("currentToolOptions"));           

        ret = ret.getObjectValue(stringIDToTypeID("brush"));           

        ret = ret.getBoolean(stringIDToTypeID("interfaceIconFrameDimmed"));           

        return ret;

        }

    catch (e) { alert(e); }

    }

///////////////////////////////////////////////////////////////////////////////////////////////////

function set_brush_space_checkbox(val)

    {

    try {

        var desc = new ActionDescriptor();

        var ref = new ActionReference();

        ref.putEnumerated( charIDToTypeID( "Brsh" ), charIDToTypeID( "Ordn"), charIDToTypeID( "Trgt" ) );

        desc.putReference( charIDToTypeID( "null" ), ref );

        var desc1 = new ActionDescriptor();

        desc1.putBoolean( stringIDToTypeID("interfaceIconFrameDimmed"), val);

        desc.putObject( charIDToTypeID( "T   " ), charIDToTypeID( "Brsh" ), desc1 );

        executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );

        ref = null;

        desc = null;

        desc1 = null;

        }

    catch (e) { alert(e); throw(e); }

    }

 

 

TOPICS
Actions and scripting , Windows

Views

117
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

Explorer , Mar 13, 2025 Mar 13, 2025

It seems to work now! Here is the script if someone needs it.

 

var r = new ActionReference();
r.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID( "tool" ) );
r.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var ret = executeActionGet(r);
var options = ret.getObjectValue(stringIDToTypeID("currentToolOptions"));
var tool = ret.getEnumerationType(stringIDToTypeID("tool"));
var brush = options.getObjectValue(stringIDToTypeID("brush"));
var checkSpacing = brus

...

Votes

Translate
Adobe
Community Expert ,
Mar 12, 2025 Mar 12, 2025

Copy link to clipboard

Copied

I am not sure what you mean by »it resets the brush to the default settings«, custom settings seem to be maintained here. 

Could you please post screenshots with the pertinent Panels (Toolbar, Layers, Brush Settings, Options Bar, …) visible to illustrate? 

Votes

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 ,
Mar 12, 2025 Mar 12, 2025

Copy link to clipboard

Copied

Thank you for the reply! Sorry, it does save most of the settings. But I meant to say that it changes the brush tip shape.

 

Zipo4323_0-1741782302734.pngZipo4323_1-1741782361377.png

 

Votes

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 ,
Mar 12, 2025 Mar 12, 2025

Copy link to clipboard

Copied

It seems you are talking about sampled brush-tips.

Which is unfortunate … if I remember correctly that limitation for setting currentToolOptions has come up on the Forum (respectively one of its previous incarnations) a while back and it seems the failure has not been fixed since. 

 

I suppose one could include a check for "sampledData" and have the Script simply not do anything if the current brush utilizes a sampled brush, but otherwise I doubt there is a solution in ESTK Scripting. 

Maybe UXP Scripting can achieve it, though. 

Votes

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 ,
Mar 12, 2025 Mar 12, 2025

Copy link to clipboard

Copied

Got it. Thank you for the response. Maybe someone with knowledge of UXP would help.

Votes

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 ,
Mar 13, 2025 Mar 13, 2025

Copy link to clipboard

Copied

It seems to work now! Here is the script if someone needs it.

 

var r = new ActionReference();
r.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID( "tool" ) );
r.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var ret = executeActionGet(r);
var options = ret.getObjectValue(stringIDToTypeID("currentToolOptions"));
var tool = ret.getEnumerationType(stringIDToTypeID("tool"));
var brush = options.getObjectValue(stringIDToTypeID("brush"));
var checkSpacing = brush.getBoolean(stringIDToTypeID("interfaceIconFrameDimmed"));
if (checkSpacing == true) {
var val = false;
} else {
var val = true;
};
brush.putBoolean( stringIDToTypeID("interfaceIconFrameDimmed"), val);
options.putObject( stringIDToTypeID( "brush" ), stringIDToTypeID( "null" ), brush );
var r = new ActionReference();
r.putClass( tool );
var desc = new ActionDescriptor();
desc.putReference( stringIDToTypeID( "null" ), r );
desc.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "null" ), options );
executeAction( stringIDToTypeID( "set" ), desc, DialogModes.NO );

Votes

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 ,
Mar 13, 2025 Mar 13, 2025

Copy link to clipboard

Copied

LATEST

Great! 

Votes

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