Copy link to clipboard
Copied
Hi all,
I am new in this scripting inside illustrator. I am not even sure, if my question is blunder or not.
I have a requirement, that I need to open another application by running the javascript from illustrator. Is this possible?
Thanks in advance.
Hi rarur97798982,
you can open a file in the wished application eg photoshop
#target Illustrator
var psfile = new File('~/Desktop/YourFilename.jpg');
if (psfile.exists) { photoshop.open(psfile); }
else { alert('file does not exist');}
Have fun
Copy link to clipboard
Copied
moving to Illustrator Scripting​
Copy link to clipboard
Copied
Hi rarur97798982,
you can open a file in the wished application eg photoshop
#target Illustrator
var psfile = new File('~/Desktop/YourFilename.jpg');
if (psfile.exists) { photoshop.open(psfile); }
else { alert('file does not exist');}
Have fun
Copy link to clipboard
Copied
HI, That worked. In indesign there is an option by which we can select any image and be opened with photoshop. Is there any chance of opening the image in photoshop from illustrator by using the script?
Copy link to clipboard
Copied
function unique(ain) {
var seen = {}
var aout = []
for(var i = 0; i < ain.length; i++) {
var elt = ain[i]
if (!seen[elt]) {
aout.push(elt)
seen[elt] = true
}
}
return aout
}
var doc = app.activeDocument;
var listImageFiles = [];
var i, in_file;
for(i = 0; i < doc.placedItems.length; i++) {
in_file = doc.placedItems[i].file;
listImageFiles.push(in_file);
listImageFiles = unique(listImageFiles);
}
var ii;
for(ii = 0; ii < listImageFiles.length; ii++) {
photoshop.open(listImageFiles[ii]);
}
First we put all placed images with full path into an array.
Then we use the unique function to remove any images placed more than once from the array.
In the end we open all files stored in the array in Photoshop.
To prevent errors make sure Photoshop is already running because the script is faster than app startup 🙂
Copy link to clipboard
Copied
I edited a script, crippled due to forums transition. Check if it works with readded [i] chunks.