Setting minimum brush opacity

After a lot of trial and error and taking bits from Alchemist and Simon’s suggestions , I got it to work. This is tricky as hell. It’s obvious that this part needs documentation in some form.

Here’s the complete code …

const batchPlay = require("photoshop").action.batchPlay;

// GET TOOL OPTIONS
async function getCurrentToolOptions () {
  const result = await batchPlay(
  [
     {
        "_obj": "get",
        "_target": [
           {
              "_property": "currentToolOptions"
           },
           {
              "_ref": "application",
              "_enum": "ordinal",
              "_value": "targetEnum"
           }
        ],
        "_options": {
           "dialogOptions": "dontDisplay"
        }
     }
  ],{
     "synchronousExecution": false
  });
  return result[0].currentToolOptions;
}

// SET TOOL OPTIONS
async function setCurrentToolOptions(currenttooloptions) {
  const result = await batchPlay(
  [
     {
        "_obj": "set",
        "_target": [
           {
             "_ref": "paintbrushTool"
           }
        ],
        "to": currenttooloptions
     }
  ],{
     "synchronousExecution": false
  });
}

async function test1() {
  let cto = await getCurrentToolOptions();
  cto.$opVr.minimum._value = 20;
  await setCurrentToolOptions(cto);
}

document.getElementById("test1").addEventListener("click", test1);
1 Like