Skip to main content
Inspiring
June 28, 2015
Question

History Brush Blending Mode

  • June 28, 2015
  • 5 replies
  • 1742 views

I remember some time ago following a thread on PS-Scripts.com about not been able to access and change the blending mode of the history brush through a script.

Unfortunately, PS-Scripts.com is no longer online and I was wondering if things have changed with regards to changing the History Brush blending mode through a script.

This topic has been closed for replies.

5 replies

Pedro Cortez Marques
Legend
November 11, 2015

Give a look to this.

Is it possible to script brush opacity?

I think you can use this with any brush kind tool. Just create a preset tool (they contain: all brush vars + all tool properties)

// first, prepare your historybrush tool and use this to save its preset name (or save it directly on the tool properties);

save_preset("AAAA");

// then, use this wherever you want to get the preset (including belending mode)

app.currentTool = "historyBrushTool"; // select historybrush

select_preset("AAAA");

// function to create the preset tool

function save_preset(name) {

    try {

        var desc21 = new ActionDescriptor();

        var ref18 = new ActionReference();

        ref18.putClass( stringIDToTypeID( "toolPreset" ) );

        desc21.putReference( charIDToTypeID( "null" ), ref18 );

        var ref19 = new ActionReference();

        ref19.putProperty( charIDToTypeID( "Prpr" ), charIDToTypeID( "CrnT" ) );

        ref19.putEnumerated( charIDToTypeID( "capp" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );

        desc21.putReference( charIDToTypeID( "Usng" ), ref19 );

        desc21.putString( charIDToTypeID( "Nm  " ), name );

        executeAction( charIDToTypeID( "Mk  " ), desc21, DialogModes.NO );

    } catch(e) { }

}

// function to select the preset tool

function select_preset(name) {

    try {

        var desc = new ActionDescriptor();

        var ref = new ActionReference();

        ref.putName( stringIDToTypeID( "toolPreset" ), name );

        desc.putReference( charIDToTypeID( "null" ), ref );

        executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );

        ref = null;

        desc = null;

    } catch(e) { }

}

Inspiring
November 9, 2015

I'm having a similar issue – I would like to switch the blend mode of a brush from Normal to Clear.  I know that the shortcuts do that, but my goal is to be able to record the action and since this event is not recordable… here I am asking for help.

It would be grate to find a solution or a work around.

I've tried:

1. Script listener - doesn't work, no event is captured

2. Actions - do not record

3. and I looked through the reference guide for photoshop JS scripting for sample code that I could rework (I'm no programmer)

4. Of course Google search but nothing there

The closest thing I found was this: toggle brush mode 'Behind' on/off with keyboard shortcut? But the scrip is no longer available…

I was thinking of an alternative… if there's a ways to write a script that executes the keyboard shortcut that may do the trick, but I've not fount any way of doing that with code.

Any help would be greatly appreciated.

Cheers,

C

JJMack
Community Expert
Community Expert
November 9, 2015

I do not know if this will work or not.  It may.  If you want a script that toggles between two states you need to have a way to know the current state  and if the is not possible to pick a state set that state and set some state indicator that you can test to know the current state.  With a Photoshop scriptt it is possible to set a custom option or record the current state some how.

If you have the state indicator you also need to be able to switch states.  As you have found some thing are not  recorded. The scriptlistener does nothing when something can not be recorded. There may also be no DOM interface to switch the state or a standard menu item to switch states.

So what can one try?  Often over look is the ability to set some none standard things. What do I mean?  Before I get to that. There is a problem with what you want to do.  For what you want to do in not possible in Photoshop.  While there is a normal blend mode there is no "Clear" blend mode. You would need to write a Plug-in to implement a new feature for Photoshop.    However I believe it would be possible to toggle between to blending mode that are possible.  Often overlook are Presets.   Preset you define/create can be use in Photoshop automation.  The Automation will fail it these name preset have not been added to you Photoshop presets.   You will see that selecting a preset will record in Actions and be recorded by the Scriptlistener.  So you can create a two history brush presets.  "Normal" and "Clear" and use these in your script.  "Clear" would need to set some valid blending mode.

JJMack
Inspiring
November 10, 2015

Thanks for the replay JJKack,

The blend mode "Clear" is available only for brushes an not for layers. 

Sadly I'm not a programmer and writing a plug in is definitely out of the scopes of the time I have available for this task.

My goal is be able to record my strokes with the action pallet as I'm illustrating.  Unfortunately if I switch the blend mode or change the spacing of a brush that parameter change is not recorded, and when I play it back… well the end result is not what it I would expect.

The "Clear" mode is a really handy mode, it practically turns each brush into an eraser, so that one can work in positive and negative shapes.  I could create an eraser tool for every brush but that is really an unusable workaround for my workflow and it still leaves the issue that any other bush adjustment (besides brush size) does not get recorded.

Hopefully someone else has a work around that make sense for this.

c.pfaffenbichler
Community Expert
Community Expert
June 29, 2015

In post 11 xbytor provides a link to an archived version of ps-scripts.com:

PS-Scripts.com temporarily suspended?

JJMack
Community Expert
Community Expert
June 29, 2015

I think if you set a tool preset for the history brush with the blending mode you want.  You could use scriptlistener action manager code to select the preset by preset name. The would select the history brush tool with the settings you want.

There are few Photoshop scripting resources on the web. Only a few Photoshop Books will cover Photoshop in any depth.

Adobe has some documentation on the web over years I have downloaded some of their documents.

JJMack
StrongBeaver
Legend
June 29, 2015

The site just abruptly ceased to exist. Thanks for the heads up ian. 

IanBarberAuthor
Inspiring
June 29, 2015

I have just read elsewhere that unfortunately, the owner of the site Mr Mike Hale passed away which is why I am guessing the site has been taken down.
although I never met or spoke to Mike, I found some of the information, code snippets and help on his site to be excellent.

Ian

StrongBeaver
Legend
June 29, 2015

Ps-Scripts.com is dead, did this happen recently, can anyone verify ? If so the only source for scripting in Photoshop is the Adobe communities.