Copy link to clipboard
Copied
Hi.
i want to open a .ai file in illustrator using javascript.
1.my file structure is like this.
2.added script in main.js
the code above the function open_image is developed before and i have added this function atlast.
3. code inserted in hostscript.jsx
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.
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?
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}}');"
Copy link to clipboard
Copied
i have tried you answer but again the same error persists.
Copy link to clipboard
Copied
What about, should it be ng-click instead of click?
Copy link to clipboard
Copied
Its a jquery click event
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?
Copy link to clipboard
Copied
am getting the error after clicking it. what do you mean by the rendered html..?
Copy link to clipboard
Copied
could Some one please help me with this...?
Copy link to clipboard
Copied
When you go to debug and inspect the elements, what is the html you see?
Copy link to clipboard
Copied
Your title= attribute has no quotes, will that matter?
Copy link to clipboard
Copied
no. i have tried that too.. or could you suggest me a script to open an .ai file
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?
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..?
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.
Copy link to clipboard
Copied
I have changed that jquery function to angular function and click event to ngclick..
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.
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
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
Copy link to clipboard
Copied
you just put your filePath variable into the string:
+ ...
+ "var f = File(" + filePath + ");"
+ ...
Copy link to clipboard
Copied
what if i want to catch an error if app.open fails to open an path
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.
Copy link to clipboard
Copied
Thank you so much for the help
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
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?
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..?
Copy link to clipboard
Copied
Hey have you tried using the File.fsName property? Check out what it says?