Copy link to clipboard
Copied
I'm attempting to work around Illustrator's memory management problems with running a javascript on a large batch job by using a call from the script to the Actions based on this post: Creating a dynamic action to use with app.doScript() method. by Vsilly.
*DISCLAIMER ALERT* I can generally review code and know what it's doing - aside from creating a simple counter loop, I'm not up to speed enough to generate code from scratch. Please frame your responses keeping in mind I may need greater detailed information to overcome my lack of deeper knowledge here!
Two things:
1) Just to test, I've loaded the CSV format in Illustrator but it throws an error "Could not load the actions because the file is not valid."
I presume I'm misunderstanding the process. Is the idea behind converting the format to easily allow stuffing the entire .aia document into an array, replace the key items with the new variables, and spit out the entire file with the two variables updated in the proper .aia format?
If so, please help me understand how the code accomplishes pulling in and writing out the entire file.
2) The snippet below for the path exceeds a single line in the .aia file. The format of the .aia is to carry 64 characters per line. In the case where a path is encoded beyond 64 characters, there can be 2 or more lines. I'm very stuck on how to solve that particular issue.
var actionString = [ "string",
"string"
].join("\n");
//So my dynamic portion of the string which will be used with string replacement would look like this:
" /value [ {{number_of_characters}}",
" {{hex_encoded_path}}",
" ]",
//When the action is ready to be dispatched, a string replacement would look like this:
var myNewPath = Folder.myDocuments.toString() + "/Production";
var myNewPathEncoded = hexEncode(myNewPath); // find a hex encode function via google
var thisActionString = actionString.replace("{{hex_encoded_path}}", myNewPathEncoded).replace("{{number_of_characters}}", myNewPath.length);
//Now it's time to write the file.
var f = File(actionFileLocation);
f.open('w');
f.write(thisActionString);
f.close();
//And now it's time to load the action.
app.loadAction(actionFileLocation);
//Now we can play the action.
app.doScript("SaveAI2PDF", "Convert AI2PDF");
//Remove the .aia file:
f.remove();
//Remove the single-use dynamic action:
app.unloadAction("Convert AI2PDF", "");
Copy link to clipboard
Copied
A simple regEx or the more elaborate JavaScript equivalent string operations could easily nix your carriage returns and concatenate the lines if needed. Can't answer the rest. Never have been that much into AI scripting and too lazy to dig into the referenced post.
Mylenium
Copy link to clipboard
Copied
Thanks for the pointer. Curioussly, RegExs, even simple ones, were failing to work. Ended up manipulating the string variables to get the final output I needed.
Copy link to clipboard
Copied
And I found this tidbit from williamdowling where the number of hex characters that represents the path is divided by 2 :
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more