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

Brush Panel Transfer Mode Toggle

Engaged ,
Aug 30, 2016 Aug 30, 2016

Copy link to clipboard

Copied

Is there a way to toggle the Brush Panel Transfer mode check box with a script?

If this toggle can be scripted then a mac osx function key can be assigned to toggle the state of the Transfer check box.

I have created a Tool Preset with the Brush Panel Transfer ON and OFF.

TOPICS
Actions and scripting

Views

1.8K

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
Adobe
Community Expert ,
Aug 31, 2016 Aug 31, 2016

Copy link to clipboard

Copied

A script can  be triggered with a shortcut  using edit keyboard shortcuts. Actions can be assigned a f key short cut and that actions can use  scripts.  So yes a script can  run  with a key.  A script can be programmed  to toggle between selecting presets on and off.

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
Engaged ,
Aug 31, 2016 Aug 31, 2016

Copy link to clipboard

Copied

Can you point me to a sample  script that toggles a tool/preset on/off?

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
Community Expert ,
Aug 31, 2016 Aug 31, 2016

Copy link to clipboard

Copied

I would need to search and find one or write one but that is for you to do.

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
Engaged ,
Aug 31, 2016 Aug 31, 2016

Copy link to clipboard

Copied

That would be great help if you could provide a sample.

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
Community Expert ,
Aug 31, 2016 Aug 31, 2016

Copy link to clipboard

Copied

No I should not have to show you how to code an if  state off then select on and set state on  else select off and set state off.

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
Advocate ,
Sep 10, 2016 Sep 10, 2016

Copy link to clipboard

Copied

To the best of my knowledge, Transfer is not scriptable, so what it has been asked is not possible.

I've dug ActionDescriptors for about two hours, and I've concluded that the "currentToolOptions" descriptor cannot be set (the boolean of interest it the 'usePaintDynamics' stringID). You can get it, but not set.

Strangely enough, it's children "brush" can! So you're able to set via ActionManager code properties such as hardness, interpolation, etc.

My efforts went to this point then I've capitulated:

function toggleTransfer(val) {

  

    var s = function(s) {return stringIDToTypeID(s)}

    var ref = new ActionReference ();

    ref.putEnumerated (s('application'), s('ordinal'), s('targetEnum'));

    var brush = executeActionGet(ref).getObjectValue(s('currentToolOptions'));

    brush.putBoolean(s('usePaintDynamics'), val);

    var brushRef = new ActionReference();

    brushRef.putEnumerated( s('currentToolOptions'), s('ordinal'), s('targetEnum'));

    brushDesc = new ActionDescriptor();

    brushDesc.putReference(s('target'), brushRef);

    brushDesc.putObject(s('to'), s('currentToolOptions'), brush);

      

    executeAction(s('set'), brushDesc, DialogModes.ALL);

}

toggleTransfer(true); // fails: The command “Set” is not currently available.

Too bad, I was almost there!

Davide

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 ,
Sep 10, 2016 Sep 10, 2016

Copy link to clipboard

Copied

Thanks for your input. I appreciate your time and effort to help answer my question.

All my efforts to try to target a Stamp tool preset state have failed so far.

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
Community Expert ,
Sep 10, 2016 Sep 10, 2016

Copy link to clipboard

Copied

Many brush type attributes that can not be directly scripted can be set by scripting selecting Brush presets that have the attributes the you want.  The setting that can not be scripted are stored in the brush preset you created for Photoshop and loaded into Photoshop. When you select the preset in an action or script Photoshop will set the attributes you want for the current brush type tool as stored in the brush preset.  A brush type tool must be the current Photoshop tool for only then are you sure a brush preset can be selected. Any tool preset can be selected if the user  has set  Photoshop UI to display all tool preset not just the current tool's presets. You can not count on that however. 

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
Guide ,
Sep 11, 2016 Sep 11, 2016

Copy link to clipboard

Copied

The problem you will have is that the presets will only be of use to one brush.

This will toggle between to presets.

#target photoshop;

var PT = $.getenv("PanelTransfer");

if(PT == null || PT == "OFF"){

    $.setenv("PanelTransfer","ON");

    selectBrushPreset("Brush Panel Transfer ON"); //Name of brush preset

    }else{

     $.setenv("PanelTransfer","OFF");

    selectBrushPreset("Brush Panel Transfer OFF"); //Name of brush preset

        }

function selectBrushPreset(preset) {

var desc = new ActionDescriptor();

var ref = new ActionReference();

ref.putName( charIDToTypeID('Brsh'), preset );

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

executeAction( charIDToTypeID('slct'), 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
Community Expert ,
Sep 11, 2016 Sep 11, 2016

Copy link to clipboard

Copied

Yes presets are very specific.  Scripting brush attributes is difficult because what can be scripted changes with brush tip types and brush types. What can be scripted for round tip brushes is not valid the sampled brush tips and special brush have different attributes. So what can be directly scripted  depends on the current brush.

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
Engaged ,
Sep 11, 2016 Sep 11, 2016

Copy link to clipboard

Copied

Thanks for sharing the code snippet. It is clear and logical. Using the current Brush tool settings, I created two new presets: Brush Panel Transfer ON and Brush Panel Transfer OFF. When I run the code snippet I get the Photoshop Error 8800, The command "Select" is not currently available. Did you run across this error when running the code snippet?  I am working with PSCC 2015 and PSCC 2015.5. I get the same error in both versions.

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 ,
Sep 11, 2016 Sep 11, 2016

Copy link to clipboard

Copied

The code works for me with a brush selected and using Photoshop CS6 (Windows).

You could check the scriptlistner output when selecting one of the presets and see if there is any difference in the code

Good luck.

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 ,
Sep 12, 2016 Sep 12, 2016

Copy link to clipboard

Copied

This toggles the Paint Brush Tool Transfer mode ON/OFF in PSCC 2015.5.

The script works only with the specific Paint Brush Tool attributes recorded in the tool preset.

Given the script toggles between two presets, calling the Tool Preset Palette in the script with the run menu item command

app.runMenuItem(stringIDToTypeID ('toggleToolPresetsPalette')); causes the Tool Preset Palette to toggle open/close every time the script runs.

The idea is that when the script runs the Tool Preset Palette opens and remains open while the script toggles between the two presets for the specific tool.

Is there a different option to to open the Tool Preset Pallet which does not relay on the menuID toogleToolPresetsPallet?

The run menu item and script listener code behave the same.

#target photoshop

 

  try {

       

            var PresetName1 = "Brush Transfer ON";    // Name of tool preset

            var PresetName2 = "Brush Transfer OFF";   // Name of tool preset

            var PT = $.getenv("PanelTransfer"); 

           

            // SELECT TOOL

            setTool('paintbrushTool');

         

            // CHECK TOOL PRESET STATE

            if(PT == null || PT == "OFF"){ 

                $.setenv("PanelTransfer","ON"); 

                    SelectToolPreset (PresetName2);

                }else{ 

                 $.setenv("PanelTransfer","OFF"); 

                    SelectToolPreset (PresetName1);

                 }

            /////////// FUNCTIONS //////////////

            function setTool(tool) {

                var desc9 = new ActionDescriptor();

                var ref7 = new ActionReference();

                ref7.putClass( app.stringIDToTypeID(tool) );

                desc9.putReference( app.charIDToTypeID('null'), ref7 );

                executeAction( app.charIDToTypeID('slct'), desc9, DialogModes.NO );   

            }

            function SelectToolPreset(PresetName1) {

                var idslct = charIDToTypeID( "slct" );

                    var desc14 = new ActionDescriptor();

                    var idnull = charIDToTypeID( "null" );

                        var ref10 = new ActionReference();

                        var idtoolPreset = stringIDToTypeID( "toolPreset" );

                        ref10.putName( idtoolPreset, PresetName1);

                    desc14.putReference( idnull, ref10 );

                executeAction( idslct, desc14, DialogModes.NO );   

             }

            function SelectToolPreset(PresetName2) {

                var idslct = charIDToTypeID( "slct" );

                    var desc16 = new ActionDescriptor();

                    var idnull = charIDToTypeID( "null" );

                        var ref12 = new ActionReference();

                        var idtoolPreset = stringIDToTypeID( "toolPreset" );

                        ref12.putName( idtoolPreset, PresetName2 );

                    desc16.putReference( idnull, ref12 );

                executeAction( idslct, desc16, DialogModes.NO );                       

            }

       

        }

   

    catch(e){

    //Something went wrong

    alert ("An unexpected error occurred and the script did not complete!");

    }

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
Community Expert ,
Sep 11, 2016 Sep 11, 2016

Copy link to clipboard

Copied

If you set your Photoshop Preset UI to display all tool presets not just the current tool you should be able to run the code without the brush tool being the current tool. If you have create those two tool presets.   The Preset are requited to be in you Photoshop configuration.  To be safe the brush tool should be active.

Its complicated.

// Note:  This script only works if the correct tool for the preset is currently selected.

//        Or "current tool only" is not checked in Photoshop's  "Tool Options Bar" Presets pull-down list dialog at the bottom left. 

var ToolPresetName = "JJMack soft oval red brush" ; // The Photoshop Tool preset name that you created and saved into a set  

var ToolPresetSet  = "JJMackToolsPresetsSet";       // The SetName.tpl file need to be same folder as this Photoshop script.

try {SelectToolPreset(ToolPresetName);}

catch(e) {

  if (LoadToolPresetSet(ToolPresetSet)) {

  try {SelectToolPreset(ToolPresetName);}

  catch(e) {alert("Was unable to Select the Tools Preset " + ToolPresetName);}

  }

  else {alert("Was unable to load Tools Presets Set " + ToolPresetSet);}

}

// =================================================== Helper functions ===================================================== //

function SelectToolPreset(PresetName) {

  // === Select Preset, tool must be selected or 'show current tool only' unchecked  ===

  var desc = new ActionDescriptor();

  var ref = new ActionReference();

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

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

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

}

function LoadToolPresetSet(SetName) {

  returncode = true;

  var scriptLocation = String(findScript());

  var path = scriptLocation.substr(0, scriptLocation.lastIndexOf("/") + 1 ) ;

  var SetFile = new File(path + SetName + ".tpl");   // Requited to be in the script's folder

  if (!SetFile.exists) { returncode = false; }

  else {

  try {LoadToolsSet(SetFile);}

  catch(e) { returncode = false; }

  }

  return returncode ;

}

function LoadToolsSet(tplFile) {

  // ========load a set of Tools Presets=========================

  var desc = new ActionDescriptor();

  var ref = new ActionReference();

  ref.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID( "toolPreset"  ));

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

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

  desc.putPath( charIDToTypeID( "T   " ), new File( tplFile ) );

  desc.putBoolean( charIDToTypeID( "Appe" ), true );

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

}

// Find the location where this script resides

function findScript() {

  var where = "";

  try { FORCEERROR = FORCERRROR;}

  catch(err) { where = File(err.fileName);}

  return where ;

}

After CC 2014 you can test if the current tool is a brush type tool and if not select the Brush Tool this function only works if the brush tip is a round brush tip

//        Features(Diameter,Hardness,Angle,Roundness,Spacing,Flipy,Flipx)

//setBrushFeatures(undefined,undefined,undefined,undefined,undefined,undefined,undefined); 

//setBrushFeatures(null,null,null,null,null,null,null); 

//setBrushFeatures(13,0,0,100,25,0,0);       //Adobe Defaults

//setBrushFeatures(13,0,0,100,25,true,true); //Diameter,Hardness,Angle,Roundness,Spacing,Flipy,Flipx

//setBrushFeatures(13,0,0,100,25,1,0);       //Diameter,Hardness,Angle,Roundness,Spacing,Flipy,Flipx     

//setBrushFeatures(13,0,0,100,25,0);         //Diameter,Hardness,Angle,Roundness,Spacing,Flipy

//setBrushFeatures(13,0,0,100,1);            //Diameter,Hardness,Angle,Roundness,Spacing

//setBrushFeatures(13,0,0,50);               //Diameter,Hardness,Angle,Roundness

//setBrushFeatures(13,0,45);                 //Diameter,Hardness,Angle

//setBrushFeatures(13,50);                   //Diameter,Hardness

//setBrushFeatures(25);                      //Diameter

setBrushFeatures(20,20,20,20,2,0,0); 

//==============================================================================================//

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

    //A Brush tool must be the current tool

    if (!app.toolSupportsBrushes(app.currentTool)) selectBrush();  //CC 2014 test if the current tool is a brush type tool else select the brusg tool

    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 == null) Diameter = brushDesc.getDouble(stringIDToTypeID('diameter')); 

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

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

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

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

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

    if ( Flipx == undefined || Flipx == null ) 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( stringIDToTypeID('to'), charIDToTypeID( "Brsh" ), desc1 ); 

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

}

function selectBrush() {

  //select brush scriptlistener code

  var idslct = charIDToTypeID( "slct" );

  var desc12 = new ActionDescriptor();

  var idnull = charIDToTypeID( "null" );

  var ref8 = new ActionReference();

  var idPbTl = charIDToTypeID( "PbTl" );

  ref8.putClass( idPbTl );

  desc12.putReference( idnull, ref8 );

  executeAction( idslct, desc12, DialogModes.NO );

}

  

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
Community Expert ,
Sep 12, 2016 Sep 12, 2016

Copy link to clipboard

Copied

LATEST

A tought I had but it would only work with round  tip brushes.  First retieve the current brush tip attibites  (Diameter,Hardness,Angle,Roundness,Spacing,Flipy,Flipx)  do the toggle then set the brush tip attributes so I did some copy and pasting.

#target photoshop

try {

  var PresetName1 = "Brush Dynamics ON";    // Name of tool preset

  var PresetName2 = "Brush Dynamics OFF";   // Name of tool preset

  var PT = $.getenv("PanelDynamics");

  /* If User's Photoshop's Presets UI is not set to current tool only you could test

  if current tool is a brush type tool in CC 2014 and select brush dynamics presets

  for the current brush type tool the following would work.

  if (!app.toolSupportsBrushes(app.currentTool)) setTool('paintbrushTool'); 

  but there is no way to check Phothshop's UI setting

  */

  setTool('paintbrushTool');

  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'));

  // CHECK TOOL PRESET Dynamics STATE

  if(PT == null || PT == "OFF"){

  $.setenv("PanelDynamics","ON");

  SelectToolPreset(PresetName2);

  }

  else{

  $.setenv("PanelDynamics","OFF");

  SelectToolPreset(PresetName1);

  }

  var desc = new ActionDescriptor();

  var ref = new ActionReference();

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

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

  desc.putObject( stringIDToTypeID('to'), charIDToTypeID( "Brsh" ), brushDesc );

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

  }

catch(e){

  //Something went wrong

  alert(e + ': on line ' + e.line, 'Script Error', true);

  //alert ("An unexpected error occurred and the script did not complete!");

  }

/////////// FUNCTIONS //////////////

function setTool(tool) {

  var desc9 = new ActionDescriptor();

  var ref7 = new ActionReference();

  ref7.putClass( app.stringIDToTypeID(tool) );

  desc9.putReference( app.charIDToTypeID('null'), ref7 );

  executeAction( app.charIDToTypeID('slct'), desc9, DialogModes.NO );

  }

function SelectToolPreset(PresetName) {

  var idslct = charIDToTypeID( "slct" );

  var desc14 = new ActionDescriptor();

  var idnull = charIDToTypeID( "null" );

  var ref10 = new ActionReference();

  var idtoolPreset = stringIDToTypeID( "toolPreset" );

  ref10.putName( idtoolPreset, PresetName);

  desc14.putReference( idnull, ref10 );

  executeAction( idslct, desc14, DialogModes.NO );

  }

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