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

Custom Bridge menu selection

Engaged ,
May 22, 2018 May 22, 2018

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

};

TOPICS
Scripting
1.3K
Translate
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 , May 22, 2018 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 pr

...
Translate
Guide ,
May 22, 2018 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);  

  }

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

Translate
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 ,
May 22, 2018 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. 

Translate
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 ,
May 24, 2018 May 24, 2018
LATEST

Works impeccable in PSCC 2018 and OSX High Sierra. Many thanks again!

Translate
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