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

want to open .ai file in illustrator using javascript

Explorer ,
Oct 09, 2017 Oct 09, 2017

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
6.3K
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

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?

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

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

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

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

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

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

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

Its a jquery click event

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

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?

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

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

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

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

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

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

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

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

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

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

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 ,
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?

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

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..?

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

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.

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

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

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

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

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

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

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

you just put your filePath variable into the string:

+ ...

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

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

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

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

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.

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

Thank you so much for the help

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

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

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

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?

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

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..?

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

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

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