Hello everyone,
I am trying to open some documents in Illustrator CS4 by javascript, walk through all layers including sublayers, doing something (for now just reading the layernames and showing them at an alert), closing the document and continue with the next document in the given folder until all documents in that folder are done.
By doing so I found an error I never have seen so far and I cant figure out where it comes from exactly to get rid of it.
The Error an Illustrator error occurred: 1346458189 ('PARM') appears randomly when cycling through the layers of the document but only every second document, so I guess there might be something wrong with closing a document and realeasing all references but I could not figure out what.
Maybe someone got an idea on this problem? Posting my sourcecode (just a simple test-code) below.
#target illustrator
var sourceFolderPath = "/e/TestAI";
var destinationFolderPath = "/e/TestZielverzeichnis";
var fileNameDefinition = "*.ai";
var sourceFolder = new Folder(sourceFolderPath);
var destinationFolder = new Folder(destinationFolderPath);
runCheckTool();
function runCheckTool() {
var contentInput = sourceFolder.getFiles(fileNameDefinition);
var fileRef;
var docRef;
for (var i = 0; i < contentInput.length; i++) {
fileRef = null;
docRef = null;
try {
fileRef = new File(contentInput[i]);
docRef = open(fileRef);
} catch(e) {
alert("# 1: " + e);
}
try{
checkLayers(docRef.layers);
} catch(e) {
alert("# 2: " + i + " " + e);
}
try {
docRef.close(SaveOptions.DONOTSAVECHANGES);
alert("end file index: " + i);
} catch(e) {
alert("#3: " + e);
}
}
}
function checkLayers(layerRef) {
var countLayers = layerRef.length;
for (var j = countLayers - 1; j >= 0; j--) {
if(layerRef[j].layers.length > 0) {
checkLayers(layerRef[j].layers);
}
alert ("Layer: " + layerRef[j].name);
}
}
![Screenshot001.png]()