Skip to main content
Inspiring
May 22, 2018
Answered

Custom Bridge menu selection

  • May 22, 2018
  • 1 reply
  • 1275 views

My Bridge app has a custom top menu with submenu items. Each submenu item calls a separate Photoshop script.

For example:

My Bridge Menu                         Call

-- New Project Scaffold      ->     projectScaffold.jsx

-- File Prep                         ->      filePrep.jsx

-- File Versioning                ->      fileVersioning.jsx

-- Layer Assembly              ->      layerAssembly.jsx   

I am considering  consolidating the Photoshop scripts into one and having the Bridge submenu items call a specific function in the comb Photoshop script.

For example:

My Bridge Menu                          Call                                   Function

-- New Project Scaffold      ->     comboScript.jsx      ->      projectScaffold( );

-- File Prep                         ->      comboScript.jsx      ->      filePrep( );

-- File Versioning                ->      comboScript.jsx      ->      fileVersioning( );

-- Layer Assembly              ->      comboScript.jsx      ->      layerAssembly( );

If possible, can the script() function below,  call the projectScaffold( ) function in the Photoshop comboScript.jsx ? 

If so how I do modify the script function?

projectScaffold.onSelect  = function () {   

  function script(){  

      var scriptName = "comboScript.jsx";  

      var f = File(app.path + "/presets/scripts/" + scriptName); 

      $.evalFile(f); 

  } 

  var bt = new BridgeTalk;  

  bt.target = "photoshop";  

  bt.body = " ftn = " + script.toSource() + "; ftn();"; 

  bt.send(8);    

};

This topic has been closed for replies.
Correct answer SuperMerlin

Okay this is an example of the Photoshop comboScript.jsx

#target photoshop;

app.bringToFront();

main();

function main(){

if($.getenv("BridgeSelection") == null){

alert("No Bridge Selection has been made!");

return;

}   

var Selection = $.getenv("BridgeSelection");

$.setenv("BridgeSelection","");

switch (Number(Selection)){

    case 1 :  projectScaffold(); break;

    case 2 :  filePrep(); break;

    case 3 :  fileVersioning(); break;

    case 4 :  layerAssembly();  break;

    default : break;

    }

};

function projectScaffold(){

    alert("projectScaffold");

};

function filePrep(){

    alert("filePrep");

};

function fileVersioning(){

    alert("fileVersioning");

};

function layerAssembly(){

    alert("layerAssembley");

}

Here are the Bridge examples...

/////////////////////////////////////////////////////////////////////

projectScaffold.onSelect  = function () {   

  function script(){ 

      /* projectScaffold */

      /*sets a variable in Photoshop */

     $.setenv("BridgeSelection","1");

      var scriptName = "comboScript.jsx"; 

      var f = File(app.path + "/presets/scripts/" + scriptName);

      $.evalFile(f);

  }

  var bt = new BridgeTalk; 

  bt.target = "photoshop"; 

  bt.body = " ftn = " + script.toSource() + "; ftn();";

  bt.send(8); 

  }

  /////////////////////////////////////////////////////////////////////

  filePrep.onSelect  = function () {

    function script(){ 

      /* filePrep */

     $.setenv("BridgeSelection","2");

      var scriptName = "comboScript.jsx"; 

      var f = File(app.path + "/presets/scripts/" + scriptName);

      $.evalFile(f);

  }

  var bt = new BridgeTalk; 

  bt.target = "photoshop"; 

  bt.body = " ftn = " + script.toSource() + "; ftn();";

  bt.send(8);  

  }

  //////////////////////////////////////////////////////////////////////////

  fileVersioning.onSelect  = function () {

      function script(){ 

      /* fileVersioning*/

     $.setenv("BridgeSelection","3");

      var scriptName = "comboScript.jsx"; 

      var f = File(app.path + "/presets/scripts/" + scriptName);

      $.evalFile(f);

  }

  var bt = new BridgeTalk; 

  bt.target = "photoshop"; 

  bt.body = " ftn = " + script.toSource() + "; ftn();";

  bt.send(8);  

  }

  //////////////////////////////////////////////////////////////////////////

  layerAssembly.onSelect  = function () {

        function script(){ 

      /* layerAssembly */

     $.setenv("BridgeSelection","4");

      var scriptName = "comboScript.jsx"; 

      var f = File(app.path + "/presets/scripts/" + scriptName);

      $.evalFile(f);

  }

  var bt = new BridgeTalk; 

  bt.target = "photoshop"; 

  bt.body = " ftn = " + script.toSource() + "; ftn();";

  bt.send(8);  

  }

  //////////////////////////////////////////////////////////////////////////

1 reply

SuperMerlin
SuperMerlinCorrect answer
Inspiring
May 22, 2018

Okay this is an example of the Photoshop comboScript.jsx

#target photoshop;

app.bringToFront();

main();

function main(){

if($.getenv("BridgeSelection") == null){

alert("No Bridge Selection has been made!");

return;

}   

var Selection = $.getenv("BridgeSelection");

$.setenv("BridgeSelection","");

switch (Number(Selection)){

    case 1 :  projectScaffold(); break;

    case 2 :  filePrep(); break;

    case 3 :  fileVersioning(); break;

    case 4 :  layerAssembly();  break;

    default : break;

    }

};

function projectScaffold(){

    alert("projectScaffold");

};

function filePrep(){

    alert("filePrep");

};

function fileVersioning(){

    alert("fileVersioning");

};

function layerAssembly(){

    alert("layerAssembley");

}

Here are the Bridge examples...

/////////////////////////////////////////////////////////////////////

projectScaffold.onSelect  = function () {   

  function script(){ 

      /* projectScaffold */

      /*sets a variable in Photoshop */

     $.setenv("BridgeSelection","1");

      var scriptName = "comboScript.jsx"; 

      var f = File(app.path + "/presets/scripts/" + scriptName);

      $.evalFile(f);

  }

  var bt = new BridgeTalk; 

  bt.target = "photoshop"; 

  bt.body = " ftn = " + script.toSource() + "; ftn();";

  bt.send(8); 

  }

  /////////////////////////////////////////////////////////////////////

  filePrep.onSelect  = function () {

    function script(){ 

      /* filePrep */

     $.setenv("BridgeSelection","2");

      var scriptName = "comboScript.jsx"; 

      var f = File(app.path + "/presets/scripts/" + scriptName);

      $.evalFile(f);

  }

  var bt = new BridgeTalk; 

  bt.target = "photoshop"; 

  bt.body = " ftn = " + script.toSource() + "; ftn();";

  bt.send(8);  

  }

  //////////////////////////////////////////////////////////////////////////

  fileVersioning.onSelect  = function () {

      function script(){ 

      /* fileVersioning*/

     $.setenv("BridgeSelection","3");

      var scriptName = "comboScript.jsx"; 

      var f = File(app.path + "/presets/scripts/" + scriptName);

      $.evalFile(f);

  }

  var bt = new BridgeTalk; 

  bt.target = "photoshop"; 

  bt.body = " ftn = " + script.toSource() + "; ftn();";

  bt.send(8);  

  }

  //////////////////////////////////////////////////////////////////////////

  layerAssembly.onSelect  = function () {

        function script(){ 

      /* layerAssembly */

     $.setenv("BridgeSelection","4");

      var scriptName = "comboScript.jsx"; 

      var f = File(app.path + "/presets/scripts/" + scriptName);

      $.evalFile(f);

  }

  var bt = new BridgeTalk; 

  bt.target = "photoshop"; 

  bt.body = " ftn = " + script.toSource() + "; ftn();";

  bt.send(8);  

  }

  //////////////////////////////////////////////////////////////////////////

Inspiring
May 22, 2018

The solution looks super! Clean and easy to follow. But not something I would have been able to figure out on my own. Thank you again SuperMerlin for taking the time to answer my questions in the past and now. I will apply the code in the next couple of days.