Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamic app.doScript() actions

Community Beginner ,
Dec 12, 2019 Dec 12, 2019

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." 

 

Screen Shot 2019-12-12 at 07.05.33.png

 

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.

 

/value [ 100
2f55736572732f45726963682f446f63756d656e74732f436c69656e74732f46
7573696f6e4472696e6b77443562f50726f6a656374732f46616e6174696373
446174614d657267652f50726f64756374696f6e2f706c616365686f6c646572
2e706466
]
 
By the way, making a func call to decode/encode and return string/hex is one piece that does work.
 
For Referecne, from Vsilly's original post:
 

 

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", "");

 

 
 
 
TOPICS
Scripting
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Dec 12, 2019 Dec 12, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 23, 2019 Dec 23, 2019

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 23, 2019 Dec 23, 2019
LATEST

And I found this tidbit from williamdowling  where the number of hex characters that represents the path is divided by 2 :

Path Length / 2 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines