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…
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…
Replace
cto.$opVr.minimum._value = 20;
by this
cto.opacity = 50;
@AndreasResch
Thank you. A very useful piece of code!
Thank you a lot!
Now it works for me.
Btw, the “Brush Tip Shape” can be manipulated like this: (hardness, spacing, angle, etc.)
{
_obj: 'set',
_target: [{_ref: 'brush', _enum: 'ordinal', _value: 'targetEnum'}],
to: {
_obj: 'brush',
spacing: {
_unit: 'percentUnit',
_value: 33
}
}
}
Maybe this helps someone, too.
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.
Inside currentToolOptions
:
$StmS: true
→ Current Layer$StmS: true
and $StmB: true
: → Current & Below$StmS: false
and $StmB: false
: → All layersAargh!
I suspected it, but didn’t decide to try it, it’s didn’t too obvious.
Thank you so much!
Have you got any idea how to capture the events of changing the brush settings?
Unfortunately not. Seems like they’re not put onto the “event bus”.
This would be really unfortunate and prevent a lot of nice options for brush engine plugins. They really could need some.
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
And then you can use “set” batchPlay to apply the change in your code, just like you have done
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.
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
Could you post the whole code snippet?
Here the complete code:
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);
Mistake #1: You can’t set cloneStampTool
options to the paintbrushTool
Mistake #2
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
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.
thanks a lot. now it is working fine.
what has been the issue?