Copy link to clipboard
Copied
Hey everone,
I'm wondering, it's possiable to call another script (for illustrotr) inside a runing script(indesign)?
I want to update a vector's data, but i need to open illustrator, so i'm going to do another script. So, what if i'm running the indesign script and like calling a function but calling a script for illustator to do some work and save it for us in some folder. is it possable?? and if yes how to call the illustator script? I dont want to start creating the script until I make sure that it's possable.
I'm using JS.
THANKS all.
Also, writing the body string can be tricky especially with more complex functions. Here’s an alternative where I’ve written the AI function below, and converted it to a string for the bt.body. This also shows how to return a string or array back to InDesign:
//the script application
#target indesign
#targetengine "session"
//the bridge to the appication we want to talk to
var bt = new BridgeTalk();
bt.target = "illustrator";
//for complex functions it can be easier to convert the fu
...
Copy link to clipboard
Copied
Hi,
If I understand correctly you would like to open Illustrator file while you are running the script in Indesign. If this is the case, then yes it is possible. You can read the following thread
The above thread - it open Illustrator file from Photoshop. So, you can update few things as per your requirement.
Copy link to clipboard
Copied
I've tried it. but i faced this problem{ script alert (ERROR: TARGET COULDN'T BE LAUNCHED) }, why??
Copy link to clipboard
Copied
Do you have Illustrator installed on your machine?
Also could you please share the video and code how you are trying to execute it?
Copy link to clipboard
Copied
Yes, it's installed. Also, I'm running the indesign code.
However, i'm going to send image and i need to open the image in illustator to change text, save it return back to indesign and continue the work. when i edit .ai image inside indesign document it redirect me to illustrotr to change the text and when i click save it changed automatic in the indesign. I want to send the image and data to illustrotr to change the text and come back. I hope it's possiable.
This's the code: (also i just want to test if it's work so i can start coding)
Main();
function Main() {
//write the data in each frame //rectangles
var doc = app.activeDocument;
alert("test")
createPlaceholders();
function createPlaceholders() {
var masterfile = "C:/Users/me/Desktop/image.ai"
var bt = new BridgeTalk();
bt.target = "Illustrator";
bt.body = "app.open('" + masterfile + "');";
bt.onResult = function (inBT) {
result = eval(inBT.body);
};
bt.onError = function (inBT) {
alert(inBT.body);
};
bt.send(8);
};
}
Copy link to clipboard
Copied
I am getting an error while executing your script. Please update following line in your code
bt.body = "app.open('" + masterfile + "');";
with
bt.body = "app.open(new File('" + masterfile + "'));";
app.open requires a File object and you are just sending the path, not file object.
Let's try this and it will open your image.ai file in Illustrator.
Copy link to clipboard
Copied
I've replace it but still facing the same error.
Copy link to clipboard
Copied
Hi,
Could you please post a video whiel exeuting your script. It will be easy for us to look how you are running and we can help you out in right direction.
Copy link to clipboard
Copied
Also, writing the body string can be tricky especially with more complex functions. Here’s an alternative where I’ve written the AI function below, and converted it to a string for the bt.body. This also shows how to return a string or array back to InDesign:
//the script application
#target indesign
#targetengine "session"
//the bridge to the appication we want to talk to
var bt = new BridgeTalk();
bt.target = "illustrator";
//for complex functions it can be easier to convert the function into a string for the message body.
//in this case I’ve included the ai function below as a string and added a variable to be sent mynum
bt.body = "var mynum = 50; var f = " + aiScript.toString() + "\rf();";
//wait for the result and run the swatch function
bt.onResult = function(resObj) {
//get a string sent back from AI
alert("Illustrator sent this message back to InDesign. " + resObj.body.toString());
//you could also send an array back and get it in InDesign like this:
//var aiarray = resObj.body.split(',');
}
//error handler
bt.onError = function( inBT ) { alert(inBT.body); };
//send to Illustrator
bt.send();
/**
* A Illustrator function
* @return string
*
*/
function aiScript() {
//Illustrator is running
//an alert shown in Illustrator
alert ("From Illustrator: Opening a Document" );
//open a file
var masterfile = "C:/Users/me/Desktop/image.ai"
var doc = app.open(new File(masterfile))
//a string returned back to InDesign
var s = " Your document has been opened. Its name is " +doc.name + ". The sent variable mynum = " + mynum;
return s
}
Copy link to clipboard
Copied
I've tried the code, there is nothing at all!! No connection with illustrtor i don't know why!
Thanks for your time.
Copy link to clipboard
Copied
Are you running the script from Extend Script Toolkit? Does the script finish or do you get an error?
Copy link to clipboard
Copied
I just ran this it worked for me. Do you have your image.ai in this location.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now