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

How to call illustrator script inside inDesign script???

Participant ,
Aug 23, 2020 Aug 23, 2020

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.

TOPICS
Activation billing and install , Bug , EPUB , Feature request , How to , Import and export , InCopy workflow , Performance , Print , Publish online , Scripting , SDK , Sync and storage , Type
1.5K
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

Community Expert , Aug 23, 2020 Aug 23, 2020

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
...
Translate
Community Expert ,
Aug 23, 2020 Aug 23, 2020

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 

https://community.adobe.com/t5/photoshop/address-illustrator-from-photoshop-script/m-p/11373918?page...

 

The above thread - it open Illustrator file from Photoshop. So, you can update few things as per your requirement.

Best regards
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
Participant ,
Aug 23, 2020 Aug 23, 2020

I've tried it. but i faced this problem{ script alert (ERROR: TARGET COULDN'T BE LAUNCHED) }, why??

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
Community Expert ,
Aug 23, 2020 Aug 23, 2020

Do you have Illustrator installed on your machine?

Also could you please share the video and code how you are trying to execute it?

Best regards
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
Participant ,
Aug 23, 2020 Aug 23, 2020

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

}
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
Community Expert ,
Aug 23, 2020 Aug 23, 2020

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. 

 

Best regards
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
Participant ,
Aug 23, 2020 Aug 23, 2020

I've replace it but still facing the same error.

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
Community Expert ,
Aug 23, 2020 Aug 23, 2020

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.

Best regards
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
Community Expert ,
Aug 23, 2020 Aug 23, 2020

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
}  

 

 

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
Participant ,
Aug 23, 2020 Aug 23, 2020

I've tried the code, there is nothing at all!! No connection with illustrtor i don't know why!

Thanks for your time.

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
Community Expert ,
Aug 24, 2020 Aug 24, 2020

Are you running the script from Extend Script Toolkit? Does the script finish or do you get an error?

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
Advisor ,
Aug 25, 2020 Aug 25, 2020
LATEST

I just ran this it worked for me. Do you have your image.ai in this location.

C:/Users/me/Desktop/image.ai
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