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

How to Set Current Tool Opacity to 100%?

Participant ,
Aug 27, 2016 Aug 27, 2016

Copy link to clipboard

Copied

Hello, I'm trying to set opacity of paint brush tool to 100%. I tried many ways but could not find it, I tried to record an action but it did not record. Then I installed scriptlistener and got script below but it does not work either. It throws an error at the last line ;

executeAction( idtoolModalStateChanged, desc69, DialogModes.NO );

Here is scriptlistener's output;

var idtoolModalStateChanged = stringIDToTypeID( "toolModalStateChanged" );

    var desc69 = new ActionDescriptor();

    var idLvl = charIDToTypeID( "Lvl " );

    desc69.putInteger( idLvl, 0 );

    var idStte = charIDToTypeID( "Stte" );

    var idStte = charIDToTypeID( "Stte" );

    var idexit = stringIDToTypeID( "exit" );

    desc69.putEnumerated( idStte, idStte, idexit );

    var idTool = charIDToTypeID( "Tool" );

        var desc70 = new ActionDescriptor();

        var idIdnt = charIDToTypeID( "Idnt" );

        desc70.putString( idIdnt, """pntb""" );

        var idTtl = charIDToTypeID( "Ttl " );

        desc70.putString( idTtl, """Brush Tool""" );

    var idTool = charIDToTypeID( "Tool" );

    desc69.putObject( idTool, idTool, desc70 );

    var idKnd = charIDToTypeID( "Knd " );

    var idKnd = charIDToTypeID( "Knd " );

    var idPnt = charIDToTypeID( "Pnt " );

    desc69.putEnumerated( idKnd, idKnd, idPnt );

    var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );

    desc69.putBoolean( idkcanDispatchWhileModal, true );

executeAction( idtoolModalStateChanged, desc69, DialogModes.NO );

I've searched but could not find an exact answer.

(Note: In my main script I aim to create a work path point then apply a stroke with paint brush tool. So It would be still useful if there's a way to paint with a brush which has 100% opacity.)

Thanks and Best Regards.

TOPICS
Actions and scripting

Views

1.5K

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 , Jun 04, 2018 Jun 04, 2018

Modified code written by r-bin​ Photoshop CC 2018 only.

#target Photoshop;

function setOpacity(value) {   

var ar = new ActionReference();   

ar.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID( "tool" ) );   

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

var ret = executeActionGet(ar);   

var tmp = ret.getObjectValue(stringIDToTypeID("currentToolOptions"));   

var tool = ret.getEnumerationType(stringIDToTypeID("tool"));

var ad = new ActionDes

...

Votes

Translate

Translate
Adobe
Community Expert ,
Aug 27, 2016 Aug 27, 2016

Copy link to clipboard

Copied

Many things you can do in Photoshop are nor record-able in Actions. If something can not be recorded in an action the Scriplistener Plug-in will not record anything either for it record action manager code.   Adobe introduce tool recording a few release ago you may be able to record brush opacity changes with that feature. I do not use this feature for I do not find it useful for general work. It only woks well on same size documents.   However, if you install the scriptlistener plug-in Adobe will disable the tool recording feature.

You best bet is to use Prush Presets Opacity setting should be recorded in  brush presets. You can select Brush presets in actions ant the selection will record in you action..

JJMack

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
Enthusiast ,
Jun 04, 2018 Jun 04, 2018

Copy link to clipboard

Copied

///////////////////////////////////////// Set Brush

setBrushFeatures(170, 80,undefined,undefined,1,undefined,undefined);

 

function setBrushFeatures(Diameter,Hardness,Angle,Roundness,Spacing,Flipy,Flipx) {

    var ref = new ActionReference();

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

    var appDesc = executeActionGet(ref);

    var toolDesc = appDesc.getObjectValue(stringIDToTypeID('currentToolOptions'));

    var brushDesc = toolDesc.getObjectValue(stringIDToTypeID('brush'));

    if (Diameter == undefined) Diameter = brushDesc.getDouble(stringIDToTypeID('diameter'));

    if (Hardness == undefined) Hardness = brushDesc.getDouble(stringIDToTypeID('hardness'));

    if (Angle == undefined ) Angle = brushDesc.getDouble(stringIDToTypeID('angle'));

    if (Roundness  == undefined) Roundness = brushDesc.getDouble(stringIDToTypeID('roundness'));

    if (Spacing == undefined) Spacing = brushDesc.getDouble(stringIDToTypeID('spacing'));

    if (Flipy == undefined) Flipy = brushDesc.getBoolean(stringIDToTypeID('flipY'));

    if (Flipx == undefined) Flipx = brushDesc.getBoolean(stringIDToTypeID('flipX'));

    var desc = new ActionDescriptor();

    var ref = new ActionReference();

    ref.putEnumerated( charIDToTypeID( "Brsh" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );

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

    var desc1 = new ActionDescriptor();

    desc1.putDouble(stringIDToTypeID('diameter'), Diameter);

    desc1.putDouble(stringIDToTypeID('hardness'), Hardness);

    desc1.putDouble(stringIDToTypeID('angle'), Angle);

    desc1.putDouble(stringIDToTypeID('roundness'), Roundness);

    desc1.putUnitDouble( stringIDToTypeID('spacing'), charIDToTypeID('#Prc'), Spacing);

    desc1.putBoolean(stringIDToTypeID('flipY'), Flipy);

    desc1.putBoolean(stringIDToTypeID('flipX'), Flipx);

    desc.putObject( charIDToTypeID( "T   " ), charIDToTypeID( "Brsh" ), desc1 );

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

}

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
New Here ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

Hi guys,
I have this small photoshop script to change the current brush hardness which works fine, however it has a sideeffect which i cannot find the reason for.

try {
 var desc1 = new ActionDescriptor();
 var ref1 = new ActionReference();
 ref1.putEnumerated(charIDToTypeID('Brsh'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
 desc1.putReference(charIDToTypeID('null'), ref1);
 var desc2 = new ActionDescriptor();
 desc2.putDouble(stringIDToTypeID('hardness'),  " + size + ");
 desc1.putObject(charIDToTypeID('T   '), charIDToTypeID('Brsh'), desc2);
 executeAction(charIDToTypeID('setd'), desc1, DialogModes.NO);
 'SUCCESS';
}";
catch(e) {";
 'ERROR';
}";

 Whenever I run this script it sets the hardness correct but it also set the brush radius to 25 each time, no matter what the original radius was.

Any ideas what I am doing wrong? 

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 ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

Your code is malfunctional:

 

sTT = stringIDToTypeID; (reference = new ActionReference())
.putEnumerated(sTT('brush'), sTT('ordinal'), sTT('targetEnum'));
(descriptor1 = new ActionDescriptor()).putReference(sTT('null'), reference)
descriptor2 = new ActionDescriptor(), object = {diameter: 33, hardness: 33}
for(iterator in object) descriptor2.putDouble(sTT(iterator), object[iterator])
descriptor1.putObject(sTT('to'), sTT('brush'), descriptor2)
executeAction(sTT('set'), descriptor1)

 

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
New Here ,
Jul 29, 2021 Jul 29, 2021

Copy link to clipboard

Copied

Thank you very much for your reply, I think I made a mistake by adding this post to another, not sure what went wrong with that. Apologies 

If I read your script correctly, the thing I was missing was that I also need to add the diameter if I change the hardness (or any other attribute of the brush) ? The rest seems to be the same although with a different syntax/style.

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 ,
Jul 29, 2021 Jul 29, 2021

Copy link to clipboard

Copied

LATEST

It seems some attributes must be set if you don't want them to be reseted to default. Ps. this is right place for yout post (that was moved), as here's Pedro Cortez Marques example code.

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 ,
Jun 04, 2018 Jun 04, 2018

Copy link to clipboard

Copied

Modified code written by r-bin​ Photoshop CC 2018 only.

#target Photoshop;

function setOpacity(value) {   

var ar = new ActionReference();   

ar.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID( "tool" ) );   

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

var ret = executeActionGet(ar);   

var tmp = ret.getObjectValue(stringIDToTypeID("currentToolOptions"));   

var tool = ret.getEnumerationType(stringIDToTypeID("tool"));

var ad = new ActionDescriptor();   

ar = new ActionReference();

ar.putClass( tool );

ad.putReference( charIDToTypeID( "null" ), ar );   

if (value != undefined) tmp.putUnitDouble( stringIDToTypeID( "opacity" ), charIDToTypeID( "#Pxl" ), value );

ad.putObject( charIDToTypeID( "T   " ), charIDToTypeID( "Ordn" ), tmp );

executeAction( charIDToTypeID( "setd" ), ad, DialogModes.NO );   

}   

setOpacity(100);

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