• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Photoshop Tool Preset Parameters via Script

Engaged ,
Feb 20, 2021 Feb 20, 2021

Copy link to clipboard

Copied

Basically, I switch between the stamp tool preset and the mixer brush preset.

Often I end up adjusting the tool size and hardness depending on image characteristics. 

 

Is it possible to script a stamp tool preset that includes all the tool parameters except the stamp tool size and hardness? The idea here is to inherit the last used brush size and hardness.

 

Alternatively, is it possible to edit a toolPrest.tpl file to edit the tool size and hardness parameters to undefined?

 

TOPICS
Actions and scripting

Views

3.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Feb 21, 2021 Feb 21, 2021

Try this code. Script uses Photoshop events and launches itself when notifications appear, so be sure to save it to disk before running.

On first run, the script will set up event tracking for painting to canvas and switching presets. As you paint on the canvas by any tool from object 'trackTools', Photoshop will call a script to remember the tool's name and brush options. After you switch the preset, the script will receive current tool data and try to find the previously saved brush parameters,

...

Votes

Translate

Translate
Adobe
Guide ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

This is not a keyword, but an arbitrary variable. I just wrote what came to mind - in this case, the most important thing is to pass a non-empty descriptor to the script. What exactly it contains in the context of this task does not matter.
When called from another script, we can pass a descriptor of any complexity with any number of parameters - this is very convenient in some cases.
I don't remember where I spied on passing parameters via playbackParameters. I think it was Image Processor.jsx, where is a function to call Fit Image.jsx

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

Yes, it can be anything, additionally there may be false instead of true value?! When then I remove '.putBoolean(stringIDToTypeID("runFromOtherScirpt"), true)', the other script is ran as main, so again, more precise question is how you knew you have to put boolean to descriptor to trigger script not as direct one, but inheriting playbackParameters (since there's nothing about it in ImageProcessor)?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

Perhaps I do not fully understand the question, but it seems to me that you are kidding 🙂

 

If we create an empty script with a single line alert (playbackParameters), we will see that playbackParameters is an action descriptor. Accordingly, by placing any variable (boolean, sting, integer, etc.) into it through the count property, we can understand whether this is an empty descriptor or contains some value. When script started manually, it will always be empty (at least I haven't found a way to fill it in). When launched through an action or another script, we can write variables to it, so .count will be nonzero. This principle is used in the script to understand the launch context. Basically, instead of a meaningless boolean, we could pass something useful, such as a preset name, and parse the descriptor in the script. But in the context of this task, a simple trigger is enough for us - the .count property copes with this function.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

Ah I'm sorry, that was my mistake. I tried after your previous post to use something different than boolean and that did not work, so I was sure that boolean is for reason. I have no idea what I did wrong before, but now it's exactly how you originally described that in second part of that post 😛

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

Very rarely, there are incomprehensible bugs with the call of the script when the app.notifiers is triggered - the launch of the script is blocked for some time (it feels like the event queue is overflowing), perhaps the problem was related to this.

 

It is also possible to pass a descriptor via app.playbackParameters. You can do this:

 

(d = new ActionDescriptor()).putBoolean (stringIDToTypeID("testBoolean"), true);
app.playbackParameters = d;

 

This will write the handle to the global context, which will be passed (and then erased) to any next script that runs (that is, this approach can be used not only for recording into an action, but also for exchanging parameters between scripts).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 01, 2021 Mar 01, 2021

Copy link to clipboard

Copied

LATEST

test.jsx:

 

<javascriptresource><eventid>test</eventid></javascriptresource>
executeAction(stringIDToTypeID('levels'), playbackParameters, DialogModes.ALL)

 

 and the other to trigger above one:

 

playbackParameters = executeAction(stringIDToTypeID('levels'), undefined, DialogModes.ALL), executeAction(stringIDToTypeID('test'))

 

 

Let's see if you know how to pass arguments to the script, so arguments (in 1st line) ain't empty:

 

alert(arguments.length)

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

Thank you Jazz-y for sharing your solution and to everyone else that contributed to the question. The community is lucky to have your guidance with Photoshop scripting problems.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines