How to change Brush hardness without changing it's size via batchplay


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?


To reliably change just one settings, you need to set back the whole tool options descriptor like I’ve described here:

To save you some time:

// ... require batchPlay & executeAsModal

// Have your tool selected or select it via:
executeAsModal(() =>
        _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

Again Thank you Simon! You’ve saved a lot of my time and frustration :slight_smile:

Have a great day!

1 Like

What does this do? :thinking:

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