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

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(() =>
  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