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

Scripting code for Open AI file in Illustrator......

Engaged ,
Jun 05, 2017 Jun 05, 2017

Copy link to clipboard

Copied

Hello Friends,

I am creating a html extension .

In this extension I am browsing a AI file by clicking a button .

Now I have to open browsed AI file in Illustrator.

I have to open AI TEST.ai file in Illustrator.

so I need the js code for that.

Please assist me.

Regards

Kundan

TOPICS
Scripting

Views

7.2K

Translate

Translate

Report

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 , Jun 05, 2017 Jun 05, 2017

Add open method. Before return value like below:

if(f){

app.open(f);

return f.fsName;

}

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 05, 2017 Jun 05, 2017

Copy link to clipboard

Copied

There are few way to get local files we can use.

Here is an example using Extendscript's File object:

var csi = new CSInterface();

var es = "(function (){"

  + "var f = File.openDialog('Select ai file...');"

  + "return f.fsName;})();"

csi.evalscript(es, function(cb){

  alert(cb);

  });

However, You can use Native function. Probably, its better way.

var f = window.cep.fs.showOpenDialog(false, false, "select ai file...", "", ["ai"]);

Votes

Translate

Translate

Report

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 ,
Jun 05, 2017 Jun 05, 2017

Copy link to clipboard

Copied

Hello TenA,

By using above code I am able to browse  AI file.

But it's not opening in Illustrator .

Please assist.

Regards

Kundan

Votes

Translate

Translate

Report

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 ,
Jun 05, 2017 Jun 05, 2017

Copy link to clipboard

Copied

You can add open method in Extendscript part like below:

var csi = new CSInterface();

var es = "(function (){"

  + "var f = File.openDialog('Select ai file...');"

  + "return f.fsName;"

  + "app.open(f)})();"

csi.evalscript(es, function(cb){

  alert(cb);

  });

Votes

Translate

Translate

Report

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 ,
Jun 05, 2017 Jun 05, 2017

Copy link to clipboard

Copied

Thank you TenA,

It's working but It's only browse the path not opening in illustrator.

After click on button , I am able to browse the AI path but browsed AI file is not opening in Illustrator.

Please assist.

Regards

Kundan

Votes

Translate

Translate

Report

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 ,
Jun 05, 2017 Jun 05, 2017

Copy link to clipboard

Copied

Can you show me your codes?

Votes

Translate

Translate

Report

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 ,
Jun 05, 2017 Jun 05, 2017

Copy link to clipboard

Copied

Please find the atteched code.

main.js

Illustrator.jsx

index.html

Please find file structure of extension.

Please find the above detail.

Regards

Kundan

Votes

Translate

Translate

Report

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
Valorous Hero ,
Jun 05, 2017 Jun 05, 2017

Copy link to clipboard

Copied

In JSX, where you do the application controlling, you have to write all the pertinent code for things Illustrator does - so you need to have an app.open(file) command to open the returned File from the open dialog.

Votes

Translate

Translate

Report

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 ,
Jun 05, 2017 Jun 05, 2017

Copy link to clipboard

Copied

Add open method. Before return value like below:

if(f){

app.open(f);

return f.fsName;

}

Votes

Translate

Translate

Report

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 ,
Jun 05, 2017 Jun 05, 2017

Copy link to clipboard

Copied

Thanks for reply.

Yes now it's works.

Regards

Kundan

Votes

Translate

Translate

Report

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
New Here ,
Oct 31, 2018 Oct 31, 2018

Copy link to clipboard

Copied

Hi kundan,

I need this script pls send me xxxxxxxxx.

Votes

Translate

Translate

Report

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 ,
Oct 31, 2018 Oct 31, 2018

Copy link to clipboard

Copied

LATEST

Hi,

I removed your Email address.

Please note that do not write private info in public. You can use Private Message in this forum.

Votes

Translate

Translate

Report

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 ,
Jun 05, 2017 Jun 05, 2017

Copy link to clipboard

Copied

Thanks for reply  TenA,

I am trying .

Regards

Kundan

Votes

Translate

Translate

Report

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