Skip to main content
Inspiring
September 14, 2023
Answered

Execute a photoshop script with in photoshop from an Illustrator script

  • September 14, 2023
  • 2 replies
  • 387 views

In an illustrator script that gets executed in illustrator I have the following:

 

#include "../jsx/ps.jsx"
runPScript('test 5026');

 

The ps.jsx file contains:

 

#target illustrator


function runPScript(template) {
    var bt = new BridgeTalk;
    bt.target = "photoshop";
    
    var script = 'alert("' + template + '")';

    bt.body = script;
    bt.send();
}

 

This properly sends Alert to photoshop and I get the alert.  However my goal is to run a full script.

I have another file smartObjPrep.jsx:

 

#target photoshop
app.preferences.rulerUnits = Units.PIXELS;
var doc = activeDocument;

doc.activeLayer = doc.layers.getByName("Art");
var soLayer = doc.activeLayer;
if (soLayer.kind == LayerKind.SMARTOBJECT){
...

 

Here I would like to execute this from Illustrator how would I execute the file script? 

It also doesn't have to be in illustrator cep. If I could just have photoshop just triggered to run it be fine.  I don't need a result in AI

This topic has been closed for replies.
Correct answer c.pfaffenbichler

Maybe this example can help; replace "~/Desktop/test.jsx" mit your path, in my example »test.jsx« contains a function »main« that the BridgTalk raises in Photoshop. 

#target illustrator
alert ("illustrator");
// the bridgetalk;
var bt = new BridgeTalk;
bt.target = 'photoshop';
var myScript = '\#include \"~/Desktop/test.jsx\";\n';
myScript += 'main ();\n';
myScript += 'alert (\"done in photoshop\");\n';
bt.body = myScript;
bt.send(10);

 

2 replies

c.pfaffenbichler
Community Expert
c.pfaffenbichlerCommunity ExpertCorrect answer
Community Expert
September 15, 2023

Maybe this example can help; replace "~/Desktop/test.jsx" mit your path, in my example »test.jsx« contains a function »main« that the BridgTalk raises in Photoshop. 

#target illustrator
alert ("illustrator");
// the bridgetalk;
var bt = new BridgeTalk;
bt.target = 'photoshop';
var myScript = '\#include \"~/Desktop/test.jsx\";\n';
myScript += 'main ();\n';
myScript += 'alert (\"done in photoshop\");\n';
bt.body = myScript;
bt.send(10);

 

OhmsGAuthor
Inspiring
September 15, 2023

IT HELPS THANK YOU!

c.pfaffenbichler
Community Expert
Community Expert
September 15, 2023

The BridgeTalk body needs to be a String. 

So you can either change the whole Photoshop-Script to a String and include it in the Illustrator-Script or just the code to trigger the Photoshop-Script in Photoshop. 

OhmsGAuthor
Inspiring
September 15, 2023

How can I make the code to trigger the Photoshop-Script in photoshop?

c.pfaffenbichler
Community Expert
Community Expert
September 15, 2023

Edited: Sorry, further testing was not successful.