Sg2.9
Trouble with save() ? a bug?
Recent RSS
Trouble with save() ? a bug?
Date:  24. November 2015, 02:27

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.

Re: Trouble with save() ? a bug?
Date:  25. November 2015, 08:19

I got around my problem, sort of, by having the script stop before saving and closing, then writing an ExtendScript script to save and close all the open documents. I was worried it would be problematic with the 90 documents I created, but it worked fine.

I’d still love to know if I could do this all with Scriptographer.

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Growth2 and its partner 03.08.12