# Setting minimum brush opacity

**URL:** <https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104>\
**Category:** UXP Plugin API\
**Created:** [June 16, 2021, 5:11pm UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104 "2021-06-16T17:11:24Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![assitburn](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/assitburn/32/1499_2.png) [@assitburn](https://forums.creativeclouddeveloper.com/u/assitburn)\
**Post date:** [June 24, 2021, 6:51pm UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/21 "2021-06-24T18:51:19Z")

</div>

Sorry to all of you. It was a mistake from me. I do not want to set the minimum brush opacity. I want to set the brush opacity .

A litte bit silly from me…

---

<div class="post-metadata">

**Author:** ![Alexandr\_Stroganov](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/alexandr_stroganov/32/2710_2.png) [@Alexandr\_Stroganov](https://forums.creativeclouddeveloper.com/u/Alexandr_Stroganov)\
**Post date:** [June 24, 2021, 6:59pm UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/22 "2021-06-24T18:59:41Z")

</div>

Replace  
`cto.$opVr.minimum._value = 20;`

by this  
`cto.opacity = 50;`

@AndreasResch  
Thank you. A very useful piece of code!

---

<div class="post-metadata">

**Author:** ![assitburn](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/assitburn/32/1499_2.png) [@assitburn](https://forums.creativeclouddeveloper.com/u/assitburn)\
**Post date:** [June 24, 2021, 7:02pm UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/23 "2021-06-24T19:02:31Z")

</div>

Thank you a lot!  
Now it works for me. 😉

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 24, 2021, 7:18pm UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/24 "2021-06-24T19:18:17Z")

</div>

Btw, the “Brush Tip Shape” can be manipulated like this: (hardness, spacing, angle, etc.)

```auto
{
  _obj: 'set',
  _target: [{_ref: 'brush', _enum: 'ordinal', _value: 'targetEnum'}],
  to: {
    _obj: 'brush',
    spacing: {
      _unit: 'percentUnit',
      _value: 33
    }
  }
}

```

Maybe this helps someone, too.

---

<div class="post-metadata">

**Author:** ![Alexandr\_Stroganov](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/alexandr_stroganov/32/2710_2.png) [@Alexandr\_Stroganov](https://forums.creativeclouddeveloper.com/u/Alexandr_Stroganov)\
**Post date:** [June 24, 2021, 7:24pm UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/25 "2021-06-24T19:24:34Z")

</div>

Can you please find options for Clone Stamp Tool?  
“Sample: Current Layer, Current & Below, All Layers”

I have looked through the whole object several times but cannot find these properties.

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 24, 2021, 8:29pm UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/26 "2021-06-24T20:29:18Z")

</div>

Inside `currentToolOptions`:

- `$StmS: true` → Current Layer
- `$StmS: true` and `$StmB: true`: → Current & Below
- `$StmS: false` and `$StmB: false`: → All layers

---

<div class="post-metadata">

**Author:** ![Alexandr\_Stroganov](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/alexandr_stroganov/32/2710_2.png) [@Alexandr\_Stroganov](https://forums.creativeclouddeveloper.com/u/Alexandr_Stroganov)\
**Post date:** [June 24, 2021, 8:35pm UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/27 "2021-06-24T20:35:36Z")

</div>

Aargh!  
I suspected it, but didn’t decide to try it, it’s didn’t too obvious.  
Thank you so much!

---

<div class="post-metadata">

**Author:** ![AndreasResch](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/andreasresch/32/1423_2.png) [@AndreasResch](https://forums.creativeclouddeveloper.com/u/AndreasResch)\
**Post date:** [June 25, 2021, 5:49am UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/28 "2021-06-25T05:49:07Z")

</div>

Have you got any idea how to capture the events of changing the brush settings?

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 25, 2021, 10:27am UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/29 "2021-06-25T10:27:28Z")

</div>

Unfortunately not. Seems like they’re not put onto the “event bus”.

---

<div class="post-metadata">

**Author:** ![AndreasResch](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/andreasresch/32/1423_2.png) [@AndreasResch](https://forums.creativeclouddeveloper.com/u/AndreasResch)\
**Post date:** [June 25, 2021, 10:40am UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/30 "2021-06-25T10:40:19Z")

</div>

This would be really unfortunate and prevent a lot of nice options for brush engine plugins. They really could need some.

---

<div class="post-metadata">

**Author:** ![waterheater](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/waterheater/32/1481_2.png) [@waterheater](https://forums.creativeclouddeveloper.com/u/waterheater)\
**Post date:** [July 15, 2021, 4:11am UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/31 "2021-07-15T04:11:44Z")

</div>

> [@AndreasResch](#):
>
> `currenttooloptions`

Here is another way to capture the brush setting changes, the first 8 mins of this video can help you to get the exact change for setting a brush tool (so you don’t need to get the whole brush settings and find just one line you need from hundred lines)  
[Adobe UXP: Things you need to know! #8 BatchPlay (part 3): the Alchemist inspector - YouTube](https://www.youtube.com/watch?v=qDw3mdGAG2o)

And then you can use “set” batchPlay to apply the change in your code, just like you have done

---

<div class="post-metadata">

**Author:** ![AndreasResch](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/andreasresch/32/1423_2.png) [@AndreasResch](https://forums.creativeclouddeveloper.com/u/AndreasResch)\
**Post date:** [July 18, 2021, 10:45am UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/32 "2021-07-18T10:45:36Z")

</div>

Setting the brush options is working for now. The next step would be to have a callback function for changes to the brush settings. From what I see now and by the lack of responses to the question about it, it seems that there is none. Maybe one will be introduced in the future. Until then, I will wait with any brush tool plugin ideas.

---

<div class="post-metadata">

**Author:** ![assitburn](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/assitburn/32/1499_2.png) [@assitburn](https://forums.creativeclouddeveloper.com/u/assitburn)\
**Post date:** [June 16, 2022, 8:02pm UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/33 "2022-06-16T20:02:21Z")

</div>

> [@simonhenke](#):
>
> StmS

Dear Simon,

I have tried but I am not able to set the option to Current Layer.

I have used:  
cto.$StmS = true;  
cto.$StmB = false;  
in the code Andreas Resch has posted.

Nothing is happen  
The function is running in modal state…

do you have an Idea?

Best Regards

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 16, 2022, 11:38pm UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/34 "2022-06-16T23:38:10Z")

</div>

Could you post the whole code snippet?

---

<div class="post-metadata">

**Author:** ![assitburn](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/assitburn/32/1499_2.png) [@assitburn](https://forums.creativeclouddeveloper.com/u/assitburn)\
**Post date:** [June 17, 2022, 8:40am UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/35 "2022-06-17T08:40:20Z")

</div>

Here the complete code:

```auto
const batchPlay = require("photoshop").action.batchPlay;
// GET TOOL OPTIONS
async function getCurrentToolOptions () {
  const app = require('photoshop').app;
  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 app = require('photoshop').app;
  const result = await batchPlay(
  [
     {
        "_obj": "set",
        "_target": [
           {
             "_ref": "paintbrushTool"
           }
        ],
        "to": currenttooloptions
     }
  ],{
     "synchronousExecution": false
  });
}

async function currentlayer() {
  let cto = await getCurrentToolOptions();
  cto.$StmS = true;
  cto.$StmB = flase;
  await setCurrentToolOptions(cto);
}
await require("photoshop").core.executeAsModal(currentlayer);

```

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 17, 2022, 10:00am UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/36 "2022-06-17T10:00:15Z")

</div>

> [@assitburn](#):
>
> `"_ref": "paintbrushTool"`

Mistake #1: You can’t set `cloneStampTool` options to the `paintbrushTool`

> [@assitburn](#):
>
> ` cto.$StmB = flase;`

Mistake #2 😉

---

<div class="post-metadata">

**Author:** ![assitburn](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/assitburn/32/1499_2.png) [@assitburn](https://forums.creativeclouddeveloper.com/u/assitburn)\
**Post date:** [June 17, 2022, 10:49am UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/37 "2022-06-17T10:49:31Z")

</div>

```auto
await require("photoshop").core.executeAsModal(currentlayer);
async function setclonestampToolOptions(currenttooloptions) {
  const app = require('photoshop').app;
  const result = await batchPlay(
  [
     {
        "_obj": "set",
        "_target": [
           {
             "_ref": "cloneStampTool"
           }
        ],
        "to": currenttooloptions
     }
  ],{
     "synchronousExecution": false
  });
}

async function currentlayer() {
  let cto = await getCurrentToolOptions();
  cto.$StmS = true;
  cto.$StmB = false;
  await setclonestampToolOptions(cto);
}

await require("photoshop").core.executeAsModal(currentlayer);

```

now I have used this… but still not working.

Sorry to needle you 😉

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 17, 2022, 11:21am UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/38 "2022-06-17T11:21:20Z")

</div>

Hm, not sure then, for me it was working.  
Did you set different values in the dropdown menu manually, so that the script has something to change? (maybe youre changing to the already active one).

Maybe logging `result` or an error thrown inside `try/catch` gives any hints.

---

<div class="post-metadata">

**Author:** ![assitburn](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/assitburn/32/1499_2.png) [@assitburn](https://forums.creativeclouddeveloper.com/u/assitburn)\
**Post date:** [June 17, 2022, 12:57pm UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/39 "2022-06-17T12:57:48Z")

</div>

thanks a lot. now it is working fine.

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [June 17, 2022, 1:03pm UTC](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104/40 "2022-06-17T13:03:37Z")

</div>

what has been the issue?

[Previous page](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104.md?page=1)

[Next page](https://forums.creativeclouddeveloper.com/t/setting-minimum-brush-opacity/3104.md?page=3)
