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); }
}
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
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?
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.
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.
Copy link to clipboard
Copied
Got it. Thank you for the response. Maybe someone with knowledge of UXP would help.
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 );
Copy link to clipboard
Copied
Great!