Skip to main content
Inspiring
March 12, 2025
Answered

Script for switching brush spacing on/off

  • March 12, 2025
  • 1 reply
  • 387 views

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-or-ignore/m-p/9468530

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

    }

 

 

Correct answer Zipo4323

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


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

1 reply

c.pfaffenbichler
Community Expert
Community Expert
March 12, 2025

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? 

Zipo4323Author
Inspiring
March 12, 2025

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.

 

 

Zipo4323AuthorCorrect answer
Inspiring
March 13, 2025

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


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