Copy link to clipboard
Copied
All AI files are acquired from a certain folder,
It checks whether there is an object in a certain layer in the Ai file,
I am writing a script to output text.
Below is the source.
function main(){
var basicFolderRef = new Folder("C:/AiFiles/");
var dirList = basicFolderRef.getFiles("*");
searchDir(dirList);
return true;
}function searchDir(dirList) {
for(var i=0; i< dirList.length; i++){
$.write(i + " ");
if(typeof(dirList.getFiles) == "function"){
searchDir(dirList.getFiles("*"));
}else{
var tempPath = dirList.fsName;
var tempName = tempPath.substring(tempPath.lastIndexOf('\\')+1, tempPath.length);
var extension = tempName.substring(tempName.indexOf(".")+1, tempName.length);
if(extension == "ai"){
var text = getObj(tempPath, tempName);
var doc = app.documents.getByName(tempName);
doc.close(SaveOptions.DONOTSAVECHANGES);
outFile(text);
}
}
}
}function getObj(filePath, fileName){
var fileObj = new File(filePath);
open(fileObj);
var doc = app.documents.getByName(fileName);
var text = fileName+"\t";
var center = null;
try{
center = doc.layers['center'];
var cLogo = center.layers['logo'];
var centerObjCnt = cLogo.pageItems.length;
if(centerObjCnt > 0){
text += "Y"+"\t";
}else{
text += "N"+"\t";
}
}catch(e){
$.write("retry ");
doc.close(SaveOptions.DONOTSAVECHANGES);
return getObj(filePath, fileName);
}text += "\r\n";
return text;
}function outFile(text){
var outputPath = "C:/Check/layer.txt"
var writeFile = new File(outputPath);
writeFile.open("a");
writeFile.write(text);
writeFile.close();
}main();
Open the file and locate it in the "center" layer,
Whether some object exists in the "logo" sublayer
It's a simple script.
As a premise, they all have the same layer structure,
There are about 10 main layers and about 10 to 20 sub layers
Whether an object exists in it depends on that file.
If a layer can not be acquired, reopen it again
I am making a mechanism to retry.
It is due to the following error for abomination.
1346458189('PARM')
The following is the console log when actually executed.
Actually 2000 cases were executed, but since it is long, I will paste up to 100 minutes.
-----
0 1 2 3 4 retry 5 retry 6 7 retry retry retry retry retry retry 8 9 10 11 12 13 14 15 retry retry 16 17 retry 18 retry 19 20 retry 21 retry 22 23 retry retry 24 25 26 27 28 29 30 31 32 33 34 retry retry 35 36 retry retry 37 38 retry retry 39 40 retry 41 42 retry 43 44 retry retry retry retry 45 46 47 48 49 50 51 retry 52 53 retry retry 54 55 56 57 58 59 60 61 62 retry 63 64 retry 65 66 67 68 69 70 retry retry retry 71 72 73 74 75 76 77 78 retry 79 retry 80 retry 81 82 83 84 85 86 87 88 89 90 retry 91 92 retry 93 94 95 retry 96 97 98 99 100 ...
-----
As you can see, an amazing number of "retries" are output.
I can not trust the illustrator if it is unstable so far
Is not there a good way to do it?
For example, put sleep processing in between ...
I executed it with CC2014 and CC2017, but the frequency was similar in both cases.
I recently felt the limits of the illustrator script ...
We have discovered that much of the unexplainable PARM errors often arise when a batch process is performed where a document closing command is used multiple times. In order to avoid this, I myself have resorted to doing batches by opening all of the files first and then processing. After processing, all files are closed one-by-one, and because this is the very end of the process there is no need to manipulate artwork at that point, so the error does not occur.
Copy link to clipboard
Copied
We have discovered that much of the unexplainable PARM errors often arise when a batch process is performed where a document closing command is used multiple times. In order to avoid this, I myself have resorted to doing batches by opening all of the files first and then processing. After processing, all files are closed one-by-one, and because this is the very end of the process there is no need to manipulate artwork at that point, so the error does not occur.
Copy link to clipboard
Copied
Do you open all the files manually, V? Or do you pass in a directory path and then use getFiles and then run a loop on the resulting array with an app.open(file)?
Copy link to clipboard
Copied
Yea, I have the script open all the files in one loop and process in next loop and close afterwards. If closing afterwards is not cutting it, using the menu command "quit" - as a last resort- will quit AI altogether and close every open document as part of that process.
Copy link to clipboard
Copied
::facepalm::
I've been hearing you say "open all the files first, then run the batch on the open files." for a long time now. and it never occurred to me to open the files with the script.. so i've just been going to the directory and using "open *.ai" in the CLI and then waiting until all the files are opened, then running the batch which processes and then saves/closes the file.
i have no rational explanation for why i never thought to open the files with the same script..
Copy link to clipboard
Copied
Silly-V​
Does that mean that you often get strange when you doc.close()?
certainly feel like I am told ...
that I would like to try it, but in case of opening in advance,
I think at most 10 to 20 files are limitations ...
I would like to try various things based on that story.
Thank you.
Copy link to clipboard
Copied
I opened hundred + files in advance before, I think it can handle over 20.
Copy link to clipboard
Copied
I too regularly open and process 50+ files with no problem (except the hangup at the end where illustrator is 'thinking' for a while.)
Copy link to clipboard
Copied
There is no problem to open the file to some extent?
I personally thought that a memory shortage error would come out.
I thought whether it depends on PC performance.
Although we will return to the original story, closing the document seems to raise the probability of error occurrence,
Personally, I feel that there are more errors when accessing the sub-layer (the layer under the layer).
Copy link to clipboard
Copied
The errors seem to occur when you open a file, process it, then close a file. As long as you open all the files first, then process and close each one of the open files, you should get a greatly reduced number of errors.
Copy link to clipboard
Copied
Silly-V​, williamadowling​
Certainly 50 cases were not problematic, and it was possible to execute without occurrence of an error at least once.
I appreciate your opinion.
I stopped closing every time and tried running it in about 1000 cases.
If you say why I care about the number of files,
There are about 3000 labels, but it is on that label
It is because we need to replace corporate logo all at once.
The result is a good news because the error did not occur indeed,
The illustrator became quite heavy from around 250 cases.
However, there was no exhaustion of memory as I thought,
Since there is also a problem of PC specifications, it is divided and executed, etc.
This story ends in this area.
I have been tormented by "1346458189 ('PARM')" error,
It seems that the possibility that it occurred also seems to have occurred also due to "doc.close ()" so far.
It seems likely to be worth reviewing the neighborhood.
Thank you best regard.
Copy link to clipboard
Copied
Did you successfully process 1000 files? How long did the process take?
Good that a workaround is satisfactory to your needs.
Copy link to clipboard
Copied
As for yesterday's 1000 runs, I eventually confirmed that it was working properly up to about 300, and stopped execution there.
After that, I ran it again at 1000 cases and confirmed what it is going on today.
I did not log the time, so I do not know when it stopped,
It stopped in 565 cases.
On the illustrator side, memory is insufficient and it can not be executed. And the error dialog was displayed and it was freezing.
Indeed it seems that if you open more than 500 files, the memory will run out of memory.
Considering the actual operation speed, it may be better to stop at about 200 cases.
Copy link to clipboard
Copied
This is too bad, you would have to have a script that restarts Illustrator every 200 files?
Copy link to clipboard
Copied
I think that it depends on the specifications of PC,
Considering the standard operating environment, I think that it is safe to stop at about 200 cases.
I regret that it is necessary to restart the illustrator every time ...
Copy link to clipboard
Copied
I wonder, if there's a way to simply keep it all in .jsx by using BridgeTalk to play the Illustrator scripts. Simply sending the BT message to Illustrator would start it up, and quitting it could be done in the result function at the end of BT message execution, or at the end of the actual message script. The area of concern for me is how synchronous is the quitting command.
Copy link to clipboard
Copied
Moluapple wrote a restart script some time ago. I think what you're saying is possible if the whole thing is driven by a program outside illustrator, ie ESTK.
Copy link to clipboard
Copied
do you think you can provide an actual script and actual 1000 files to test? I'd like to give it a shot at trying to figure out this PARM issue.
Copy link to clipboard
Copied
I think that the script itself can be used as it is, since the actual thing is almost the same as what is on the first place.
As for the file, since it is used in the business of the company
I can not bring it out to the outside ...