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

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

Engaged ,
Jun 05, 2017 Jun 05, 2017

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

Add open method. Before return value like below:

if(f){

app.open(f);

return f.fsName;

}

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

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

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

Hello TenA,

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

But it's not opening in Illustrator .

Please assist.

Regards

Kundan

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

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

  });

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

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

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

Can you show me your codes?

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

Please find the atteched code.

main.js

Illustrator.jsx

index.html

Please find file structure of extension.

Please find the above detail.

Regards

Kundan

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

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.

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

Add open method. Before return value like below:

if(f){

app.open(f);

return f.fsName;

}

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

Thanks for reply.

Yes now it's works.

Regards

Kundan

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

Hi kundan,

I need this script pls send me xxxxxxxxx.

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

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

Thanks for reply  TenA,

I am trying .

Regards

Kundan

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