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

want to open .ai file in illustrator using javascript

Explorer ,
Oct 09, 2017 Oct 09, 2017

Copy link to clipboard

Copied

Hi.

i want to open a .ai file in illustrator using javascript.

1.my file structure is like this.

structure.PNG

2.added script in main.js

main.PNG

the code above the function open_image is developed before and i have added this function atlast.

3. code inserted in hostscript.jsx

host.PNG

in the above file i have inserted the function openfile

4. now in html

<img ng-src="data:image/png;base64,{{item.imageByte}}"  onclick="open_image({{item.aIimagePath}});" class="hover" alt="..." data-toggle="tooltip" data-placement="top" title={{item.aIimagePath}}>

that is a image and upon clicking the image i need to open that ai file. and the item.alimagepath contains the path of the .ai file.

upon executing this an error occured stating that anonymous function.

could you please help me with this issue or how to open an .ai file.

TOPICS
Scripting

Views

5.9K

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

Valorous Hero , Oct 10, 2017 Oct 10, 2017

Well it's an angular error, so that needs to be fixed before anything can run. Do you have your remote debugger chrome inspector panel running?

Votes

Translate

Translate
Adobe
Valorous Hero ,
Oct 09, 2017 Oct 09, 2017

Copy link to clipboard

Copied

See if you're not missing quotes around the open_image function's argument. You have them in place for the jsx part openFile function, but not for the open_image's ng onclick one.

onclick="open_image('{{item.aIimagePath}}');"

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
Explorer ,
Oct 09, 2017 Oct 09, 2017

Copy link to clipboard

Copied

i have tried you answer but again the same error persists.erroe.PNG

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 ,
Oct 09, 2017 Oct 09, 2017

Copy link to clipboard

Copied

What about, should it be ng-click instead of click?

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
Explorer ,
Oct 09, 2017 Oct 09, 2017

Copy link to clipboard

Copied

Its a jquery click event

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 ,
Oct 09, 2017 Oct 09, 2017

Copy link to clipboard

Copied

So what does you html look like when it's out put? Are you getting this error after clicking the click element, or loading?

Can you do a screenshot of the rendered html in your debugger?

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
Explorer ,
Oct 10, 2017 Oct 10, 2017

Copy link to clipboard

Copied

am getting the error after clicking it. what do you mean by the rendered html..?

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
Explorer ,
Oct 10, 2017 Oct 10, 2017

Copy link to clipboard

Copied

could Some one please help me with this...?

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 ,
Oct 10, 2017 Oct 10, 2017

Copy link to clipboard

Copied

When you go to debug and inspect the elements, what is the html you see?

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 ,
Oct 10, 2017 Oct 10, 2017

Copy link to clipboard

Copied

Your title= attribute has no quotes, will that matter?

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
Explorer ,
Oct 10, 2017 Oct 10, 2017

Copy link to clipboard

Copied

no. i have tried that too.. or could you suggest me a script to open an .ai file

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 ,
Oct 10, 2017 Oct 10, 2017

Copy link to clipboard

Copied

Well it's an angular error, so that needs to be fixed before anything can run. Do you have your remote debugger chrome inspector panel running?

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
Explorer ,
Oct 10, 2017 Oct 10, 2017

Copy link to clipboard

Copied

yes.. and its solved. thanks for the help. its an angular error.

is there an tutorial for scripting illustrator extensions. whether it may be a paid one too.. no problem. could you please suggest me..?

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 ,
Oct 10, 2017 Oct 10, 2017

Copy link to clipboard

Copied

How did you solve it?

To script Illustrator using Adobe ExtendScript, it's satisfactory just to use this very forum as well as the Illustrator Javascript PDF document, here's a CS6 version.

To get help with CEP development, check out our new CEP / AddOns forum!

A very good paid resource is Davide Barranca's HTML Panels course - it is for Photoshop, but is mostly CEP oriented and describes many situations which can be used with other applications.

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
Explorer ,
Oct 10, 2017 Oct 10, 2017

Copy link to clipboard

Copied

I have changed that jquery function to angular function and click event to ngclick..

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 ,
Oct 10, 2017 Oct 10, 2017

Copy link to clipboard

Copied

That by the way was not a jquery function , just a regular html event attribute with a plain javascript function.

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
Explorer ,
Oct 11, 2017 Oct 11, 2017

Copy link to clipboard

Copied

i thought its a jquery function.. and next thing is that instead of selecting a file  from window i want to open a file through path directly

file.PNG

filePath contains the path of the image file with .ai extension. instead of opening the dialog box how to open image directly by file path.

example of filePath : \\Corp-file01.cgsinc.local\vg\VG40\LOGIN\PQA\Attachments\AI\BCDress- sen copy.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
Valorous Hero ,
Oct 11, 2017 Oct 11, 2017

Copy link to clipboard

Copied

you just put your filePath variable into the string:

+ ...

+ "var f = File(" + filePath + ");"
+ ...

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
Explorer ,
Oct 12, 2017 Oct 12, 2017

Copy link to clipboard

Copied

what if i want to catch an error if app.open fails to open an path

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 ,
Oct 12, 2017 Oct 12, 2017

Copy link to clipboard

Copied

You can keep building a try-catch statement into your js string which would return any piece of data indicative that an error occurred, and check in your callback function to examine if the returned data contains your error information.

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
Explorer ,
Oct 13, 2017 Oct 13, 2017

Copy link to clipboard

Copied

Thank you so much for the help

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
Explorer ,
Oct 13, 2017 Oct 13, 2017

Copy link to clipboard

Copied

and now the major problem is that unable to open .ai images from shared location in mac

copying the file location and searching and unable to find it. even if i save an image in illustrator and try to open that image its converting the path to a different one.

actual path :  smb://10.7.8.9/scan/skpuldanda/cheshire Cat.ai.

changed path:/Volumes/Scan/SKPULDANDA/Cheshire Cat [Converted].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
Valorous Hero ,
Oct 13, 2017 Oct 13, 2017

Copy link to clipboard

Copied

This is now an entirely different question- unfortunately I am not in an environment currently where I can test on a Mac, a network location. Do you think such a test could be performed if someone uses an external hard drive to simulate such a shared location?

Can you make a new post with just this question too?

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
Explorer ,
Oct 13, 2017 Oct 13, 2017

Copy link to clipboard

Copied

Its not necessary to connect specifically only to that shared location. what ever may be the shared location on windows if we want to access on mac it shows a path with smb prefixed. shall we discuss privately. i mean in any messenger service..?

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 ,
Oct 13, 2017 Oct 13, 2017

Copy link to clipboard

Copied

Hey have you tried using the File.fsName property? Check out what it says?

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