See, this is the first time when i am scripting for Illustrator.
when I write
3. make new swatch with properties {name:“My Swatch”, color:{red:175.0, green:50.0, blue:0.0}.
2. I really cofused how I identify those things
More info on what you’re trying to do would be helpful but here is what I know. I’m using Illustrator CS so I don’t know if it will work quite the same in 10. Open the dictionary for Illustrator 10 when you have script editor open. Anyway…
For setting a fill or stroke to overprint -
tell application "Illustrator 10"
set thisDoc to current document
set properties of every path item of thisDoc to {fill overprint:true}
set properties of every path item of thisDoc to {stroke overprint:true}
end tell
This will only work for any item that Illustrator sees as a path item (rectangles, circles, lines, outlined text, etc.)
If you need specific items you need to be able to identify them which leads to a possible problem in as far as deleting any “dots” or anything else you need to delete.
As this script is written it assumes a document is open. You may need to add code to make it open specific files.
For setting colors -
tell application "Illustrator 10"
activate
make new document with properties {height:864,width:864, color space:RGB}
set thisDoc to current document
make new swatch at end of current document with properties {name:"My Swatch", color:{red:175, green:50, blue:0}}
end tell
If you haven’t already found it there is a downloadable pdf of the Illustrator scripting guide on the Adobe website. (At least I think that is where I got it). Hope this gets you started.
Model: G5 dual 1.8
AppleScript: 1.9.3
Browser: Safari 125.12
Operating System: Mac OS X (10.3.8)
What are you trying to do with your script? Are you trying to open a file and work with that file’s contents or are you trying to make a new document and place items in it?
Yes Users are opening a file and execute an action which User has created. Now first let me clear.
They opens a file and saved it in latest version and then run the action. What actions perform I allready mention in post in three point just in the root queries.
I have given them a program and as the run it open each file and saved in latest version, But I am uable to run any action through script. So I think what action is doing I will hard code in my program, in this way User will satisfy.
Regards.
Rajeev
Its fine for setting black overprint for each and every file.
can you give me for batch files. i have 100’s of eps files in a folder.
i want to set black overprint for all the eps files in the folder and save as files in new folder.
Sorry I didn’t check up on my email and had not seen your question. I do not know if you have found your answers to your last question or not but here is the best I can do at the moment.
tell application "Finder"
set folderToGet to choose folder with prompt "Choose file folder with overprint issues."
set fileList to every file of folder folderToGet as alias list
set foldDest to choose folder with prompt "Choose file destination folder."
repeat with aFile in fileList
open aFile
tell application "Illustrator CS"
set thisDoc to current document
set selection to (every page item of current document whose fill color is {class:CMYK color info, cyan:0, magenta:0, yellow:0, black:100})
set properties of selection to {fill overprint:true}
set selection to (every page item of current document whose stroke color is {class:CMYK color info, cyan:0, magenta:0, yellow:0, black:100})
set properties of selection to {stroke overprint:true}
save thisDoc in foldDest with replacing
close current document saving no
end tell
end repeat
end tell
This of course has to open every file and perform operations on each file. Unfortunately I cannot yet figure out how to get it to select all fills or strokes that have a black value between a certain range (such as black:49 to black:100). This only will select black at 100 so if you have a black value of 99 it will not be set to overprint. There are operations for setting up printing to automatically overprint black however.
I’ve played around with AI 10. This is what I came up with. Once again remember that this will only work with a black value that you specify. It won’t do all shades of black.
tell application "Finder"
set folderSource to choose folder with prompt "Choose files for overprint."
set fileList to every file of folder folderSource as alias list
set folderDest to choose folder with prompt "Choose folder destination."
set destPath to folderDest as string
set fileCount to count folder folderSource
repeat with aFile in fileList
set fileName to name of aFile
set newFilePath to destPath & fileName & ".eps"
tell application "Adobe Illustrator 10"
activate
open aFile
set itemCount to count of every page item of current document
repeat with i from 1 to itemCount
if filled of (page item i) of current document is true then
if fill color of (page item i) of current document is {class:CMYK color info, cyan:0, magenta:0, yellow:0, black:100} then
set properties of (page item i) of current document to {fill overprint:true}
end if
end if
if stroked of (page item i) of current document is true then
set selection to (page item i) of current document
if stroke color of (page item i) of current document is {class:CMYK color info, cyan:0, magenta:0, yellow:0, black:100} then
set properties of (page item i) of current document to {stroke overprint:true}
end if
end if
end repeat
save current document in file newFilePath as eps with options {class:EPS save options, compatibility:Illustrator 10, preview:color Macintosh, embed linked files:true, include document thumbnails:true, embed all fonts:true, CMYK PostScript:true, PostScript:level 2} with replacing
close current document saving no
end tell
end repeat
end tell
That probably will not be necessary. The problem is more than likely that there are text items in the art. I made some simple art files to play with and came up with the following updated script.
tell application "Finder"
set folderSource to choose folder with prompt "Choose files for overprint."
set fileList to every file of folder folderSource as alias list
set folderDest to choose folder with prompt "Choose folder destination."
set destPath to folderDest as string
set fileCount to count folder folderSource
repeat with aFile in fileList
set fileName to name of aFile
set newFilePath to destPath & fileName & ".eps"
tell application "Adobe Illustrator 10"
activate
open aFile
try
set textCount to count of every text art item of current document
repeat with q from 1 to textCount
set selection to (text art item q) of current document
set charaCount to count every character of (text art item q) of current document
repeat with z from 1 to charaCount
if filled of ((character z) of text art item q) of current document is true then
if fill color of ((character z) of text art item q) of current document is {class:CMYK color info, cyan:0, magenta:0, yellow:0, black:100} then
set properties of ((character z) of text art item q) of current document to {fill overprint:true}
end if
end if
if stroked of ((character z) of text art item q) of current document is true then
if stroke color of ((character z) of text art item q) of current document is {class:CMYK color info, cyan:0, magenta:0, yellow:0, black:100} then
set properties of ((character z) of text art item q) of current document to {stroke overprint:true}
end if
end if
end repeat
end repeat
on error
display dialog "There doesn't seem to be any text items in the current document." giving up after 2
end try
try
set pathCount to count of every path item of current document
repeat with i from 1 to pathCount
set selection to (path item i) of current document
if filled of (path item i) of current document is true then
if fill color of (path item i) of current document is {class:CMYK color info, cyan:0, magenta:0, yellow:0, black:100} then
set properties of (path item i) of current document to {fill overprint:true}
end if
end if
if stroked of (path item i) of current document is true then
set selection to (path item i) of current document
if stroke color of (path item i) of current document is {class:CMYK color info, cyan:0, magenta:0, yellow:0, black:100} then
set properties of (path item i) of current document to {stroke overprint:true}
end if
end if
end repeat
on error
display dialog "There doesn't seem to be any path items in the current document." giving up after 2
end try
save current document in file newFilePath as eps with options {class:EPS save options, compatibility:Illustrator 10, preview:color Macintosh, embed linked files:true, include document thumbnails:true, embed all fonts:true, CMYK PostScript:true, PostScript:level 2} with replacing
close current document saving no
end tell
end repeat
end tell
This woked well on my computer with text that had multiple colors, some stroked, some not, some stroked with different color, objects with multiple colors etc.
Try working with this to see if you can modify it for your needs.
I’m late to the game, too busy at work and didnt see the topic earlier. Ahyway I may be stating the obvious, which may have been overlooked, but the fastest way to do this may be so set up an action in Illustrator to select all and run the filter>colors>overprint black with the appropriate settings, then just batch open the files and run the action via a doscript command. This is going to work faster than processing individual page items and should work with fills, strokes, and text as long as the action is set up properly. Then save as and move on to the next file.
I’ve not used the actions in Illustrator before. Here is a script using the actions. However, applescript in AI 10 does not allow selecting all items in a page (or maybe there is another way) when you write
set selection to every page item of current document.
This works in AI CS, but in AI CS, when using the action, does not perform the action on everything if it includes text. (buggy)
So this script still has to select every item one at a time and dialogs will still pop up if there are different colors (which can be tested for in the script before applying the action). Also when setting up the action for overprinting you’re still faced with selecting a certain percentage of black, such as 100% or 93% and so on, that you specify so only that percentage is set to overprint.
So here is the script I came up with.
tell application "Finder"
set folderSource to choose folder with prompt "Choose files for overprint."
set fileList to every file of folder folderSource as alias list
set folderDest to choose folder with prompt "Choose folder destination."
set destPath to folderDest as string
set fileCount to count folder folderSource
repeat with aFile in fileList
set fileName to name of aFile
set newFilePath to destPath & fileName & ".eps"
tell application "Adobe Illustrator 10"
activate
open aFile
set objectCount to count of every page item of current document
repeat with i from 1 to objectCount
set selection to page item i of current document
-- this is an action set up in AI10. You have to make sure that your names from your actions are EXACTLY the same as in your script. The first name is the action and the second name is the action set.
do script "Untitled -1" from "OverprintBlack" without dialogs
end repeat
save current document in file newFilePath as eps with options {class:EPS save options, compatibility:Illustrator 10, preview:color Macintosh, embed linked files:true, include document thumbnails:true, embed all fonts:true, CMYK PostScript:true, PostScript:level 2} with replacing
close current document saving no
end tell
end repeat
end tell
Also to Surknal, I don’t know if you know this but you can select black to overprint from the print dialog when you’re printing separations from AI 10.