Firstly, is there a way to specify a file location for save() so that I can fully automate the saving process and don’t have to respond to dialogues? I want to procedurally create and save about 100 files. I’d also like to be able to specify the file type, if I can, though .ai will work in this case.
I’m having some trouble with the save() function of Document. It seems to be linked to point text objects, as the error only happens when save() appears after I create these. I haven’t done extensive testing with other document items.
When I run the script I am presented with the Save As dialogue, then the dialogue that lets me choose the Illustrator version. The file then closes, thanks to the close() function I included, but logs “Unknown error” then “null” to the console. When I open the file again it logs “Unknown error” again, and sometimes keeps doing it, even after I’ve closed all documents. Most of the text attributes (character and paragraph styles) applied to the text in the script have not actually been applied. If I quit Illustrator and start it up again the following message appears in the console:
“Nov 24, 2015 2:52:57 AM java.util.prefs.WindowsPreferences
WARNING: Could not open/create prefs root node SoftwareJavaSoftPrefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.”
The following script reproduces the error for me:
var myDoc = new Document('My test document', 450, 300); var myPath = new Path.Rectangle(new Point(document.size.width / 3, document.size.height / 3), new Point(document.size.width / 3 * 2, document.size.height / 3 * 2)); var myTitle = new PointText(new Point(document.size.width / 2, document.size.height - 30)); myTitle.content = 'Testy McTexticle'; myTitle.characterStyle.font = app.fonts['Chaparral Pro']['Semibold']; myTitle.characterStyle.fontSize = 12; myTitle.paragraphStyle.justification = 'center'; myTitle.characterStyle.fillColor = new CMYKColor(0,1,0,0); myDoc.save(); myDoc.close();
If I leave out the text item and its attributes then it works with no problem.
I’m using Scriptographer version 2.9.073 in Illustrator CS4 on Windows 10. Let me know if there’s any other info that would be useful. I’d appreciate any help.