OK, this is very strange, and it can be replicated.
An operator has been complaining about Illustrator CS crashing when running the below script. It took me very long to pinpoint the exact cause.
Here it is:
Illustrator will only crash when an operator uses the default Illustrator Action called: “Opacity 40 Screen (selection)”
BUT, the action must be in “Button Mode” for the application to crash???. List mode, there is no crashing.
So if the Action is run on a selected object, and then the script is activated, the script will perform fine up until the point where the operator hits “Save” after the new file name has been entered. When the operator clicks “Save” the EPS options will not be set (I should see an EPS status bar). Instead Illustrator Crashes and throws up the standard Application has Quit error.
When using Script Editor, this error is generated:
AppleScript Error:
“Illustrator CS got an error: Connection is invalid.”
And the line of code that is highlighted is this:
save current document in newFile as eps with options {class:EPS save options, preview:color Macintosh, embed all fonts:true, embed linked files:false, include document thumbnails:true, compatible gradient printing:true, CMYK PostScript:true, overprint:discard, PostScript:level 3}
Btw, Not using the script and saving via the Menu>File>SaveAs will not cause Illustrator to crash. (So it has to do with the script as well.)
Can anyone explain why an action only in Button Mode can disturb such a script from functioning?
Please, any help would be greatly appreciated.
jeff
on main()
tell application "Illustrator CS"
activate
-- Get the path to the current document, if such a path exists.
try
set origPath to file path of current document as Unicode text
-- Rather uselessly, Script Editor and TextEdit return POSIX paths here.
-- Here's a trap in case Illustrator does the same.
try
origPath as alias
on error
set origPath to origPath as POSIX file as Unicode text
end try
on error
set origPath to ""
end try
-- Set a default save name for the document.
try
set currentName to name of current document
if (currentName does not end with ".eps") then set currentName to currentName & ".eps"
on error
set currentName to "Untitled.eps"
end try
-- Prompt for a save name and location. Default to the document's current location
-- if it has one, otherwise to the last one used by the application.
if ((count origPath) > 0) then
set newFile to (choose file name with prompt "Save this document as." default location (origPath as alias) default name currentName)
else
set newFile to (choose file name with prompt "Save this document as." default name currentName)
end if
-- Check that the ".eps" hasn't been lost from the name.
repeat until ((newFile as Unicode text) ends with ".eps")
set newFile to (choose file name with prompt "The name you choose must have an ".eps" extension. Save this document as." default name ((newFile as Unicode text) & ".eps"))
end repeat
-- Create the new file if it doesn't exist.
try
open for access newFile
close access newFile
end try
-- Save the document to it.
save current document in newFile as eps with options {class:EPS save options, preview:color Macintosh, embed all fonts:true, embed linked files:false, include document thumbnails:true, compatible gradient printing:true, CMYK PostScript:true, overprint:discard, PostScript:level 3}
end tell
end main
main()