Adam
March 8, 2022, 11:01am
1
Hi,
I’m trying to change brush hardness with Batchplay but no matter what I do, other parameters are being affected as well. For example size is being changed automatically to 25.
I want to adjust hardness only and keep spacing and size (diameter) unaffected.
This is the batchplay code I’m using:
{
_obj: 'set',
_target: [{_ref: 'brush', _enum: 'ordinal', _value: 'targetEnum'}],
to: {
_obj: 'brush',
hardness: {
_unit: 'percentUnit',
_value: 0
}
}
}
Anyone have the solution for that?
Thanks!
1 Like
To reliably change just one settings, you need to set back the whole tool options descriptor like I’ve described here:
I figured it out…
const toolOpt: PaintBrushToolOptionsDescriptor = getAppProperty('currentToolOptions') as PaintBrushToolOptionsDescriptor
toolOpt.$opVr.minimum._value = 50
const desc = {
_obj: 'set',
_target: {
_ref: [{ _ref: 'paintbrushTool'}],
},
to: toolOpt
}
photoshop.action.batchPlay([desc], {})
3 Notes:
You can ignore the types if you’re not using typescript, although I highly recommend it to know what’s going on inside the descriptors.
For a different t…
To save you some time:
// ... require batchPlay & executeAsModal
// Have your tool selected or select it via:
executeAsModal(() =>
batchPlay([
{
_obj: "select",
_target: {
_ref: "paintbrushTool",
},
dontRecord: true,
},
],{})
);
// Store current tool options
const toolOpt = batchPlay([
{
_obj: 'get',
_target: [
{ _property: "currentToolOptions" },
{ _ref: 'application', _enum: 'ordinal', _value: 'targetEnum' }
],
},
], { synchronousExecution: true })[0].currentToolOptions
// Set new value
toolOpt.brush.hardness._value = 50
// Write it back to the tool options
executeAsModal(() => batchPlay([
{
_obj: 'set',
_target: {
_ref: [{ _ref: 'paintbrushTool'}],
},
to: toolOpt
}
],{}))
3 Likes
Adam
March 8, 2022, 12:51pm
3
Again Thank you Simon! You’ve saved a lot of my time and frustration
Have a great day!
1 Like
I have no idea. Maybe one time it was set for every tool select event whether it should be recorded in Actions or not, until they moved it to this setting:
Just blindly guessing though…
1 Like