Copy link to clipboard
Copied
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);
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
checkLayers(layerRef
}
alert ("Layer: " + layerRef
}
}
Copy link to clipboard
Copied
I think I read somewhere that running a script a bunch of times causes the ESTK to crawl, it has a limit. Restart both the ESTK and Illustrator and try again, or also try running the script direct from within Illustrator...I may be wrong though.
Copy link to clipboard
Copied
The guide also suggests a max of 1000 files on mac and 500 on pc if you are performing a batch routine…
Copy link to clipboard
Copied
I did try runnning just in Ilustrator with the same results unfortunately. As it is, I have to restart Illustrator after every run when using ESTK. I saw the 500 max files in the guide but I'm only running on 30 or so files and the problem will start as early as the second file and definitely before the fifth file. As it is, I'll just leave the closing of the files until all files have been processed and live with the fact that scripting in Illustrator still needs work. Thanks for your tips and suggestions though, I appreciate it.
James
Copy link to clipboard
Copied
Any fix for this? I ran into this error tonight, and found your post. My script is really simple and I'm using it to collect layers into a layer named "Collected", if there are more than 2 layers. I even tried the suggested fix in this readme: http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/pdf/illustrator/scripting/Readme.txt. But I'm getting an error simply when referencing a the current executing layer. I tried referencing the current layer in the loop directly, but it still causes issues. If I get rid of the move line(which is the entire reason for this script) it works just fine.
var layerCount = actDoc.layers.length;
$.write("\n//Layer Name\nLayer Count: "+layerCount+"\n////////////////////////////////")
var placeInLayer = actDoc.layers['Collected'];
if(layerCount > 0) {
for(i=0;i<layerCount;i++) {
try{var topLayers = actDoc.layers;}
catch(" | "+e) {
$.write(e)
}
$.write("\nLayer Name: "+topLayers.name+" | Count: "+i+" ")
subLayers = topLayers.layers;
if(topLayers.name == "Collected") continue;
topLayers.move(placeInLayer,ElementPlacement.PLACEATEND);
}
}
Copy link to clipboard
Copied
I'm having this error at random too... I have pined it down to a loop that is going threw the activeDocuments swatches looking for a specific name.
Its driving me crazy!
This has been working just fine and now it keeps doing this.
I think I need to find a better way to get the color of swatch I want. I have a custom color Palette I wish I knew how to just access that and use those colors rather than having to make a swatch for the active document.
-Boyd
Copy link to clipboard
Copied
don't bother looping through the swatches.
there is a built in function to .getByName()
eg.
function getColor(swatchName){
try{
return doc.swatches.getByName(swatchName);
}catch(e){
alert("no swatch by the name of " + swatchName + " was found");
}
}
Copy link to clipboard
Copied
The issue with the error "Adobe Illustrator got an error: an Illustrator error occurred: 1346458189 ('MRAP')" is an Illustrator bug, as far as I can tell.
I am getting it for no good reason after the script errors for a legitimate reason.
I implemented an Illustrator quit - relaunch sequence which helps somewhat, but that is a pain and costs time.
Must fill bug report...
Copy link to clipboard
Copied
i've been getting a lot of MRAP errors lately with scripts i never had an error before. it's driving me nuts.
Copy link to clipboard
Copied
Solved one instance!!
I changed this:
set theArtboardRef to artboard 1
to this:
set theArtboardRef to a reference to artboard 1
Copy link to clipboard
Copied
I had the same problem. Anyone has a general solution for the problem?
Copy link to clipboard
Copied
Just upgraded from CS6 to creative cloud a few weeks ago, and now some of my scripts that worked fine with CS6 are getting random "parm" errors. I see other people are having the same problem, I will try the "tab" solution next chance I get because restarting Illustrator takes so long.
Copy link to clipboard
Copied
So it's year 2018 and i have the same problem...
I have this code:
#target illustrator
var doc = app.activeDocument;
function createOutlines(){
var tFrames = doc.textFrames;
for ( var i = 0; i < tFrames.length; i++ ) {
tFrames.createOutline();
};
};
createOutlines ();
when i'm running it separatly (no matter from AI or ESTK) it works fine,
but i want it to be a part of a bigger script, and no matter what i do the effect is the same
Copy link to clipboard
Copied
try to use app.activeDocument, or at least pass in the 'doc' into the function - maybe the problem is exacerbated by the function reaching back to a 'doc' variable out there.
Copy link to clipboard
Copied
Salut,
Oui effectivement sous Windows il y a bien ce message d'erreur, je l'ai constaté à mon tour,
il suffit d'annuler la ligne //docRef.close(SaveOptions.DONOTSAVECHANGES);
ensuite après l'exécution du script clic droit et tout fermer.
Testé sur SC6 avec cette copie un peu modifiée (sous calques jusqu'à 10 niveaux et 6 fichiers)
#target illustrator
var sourceFolderPath = "~/";
var fileNameDefinition = "*.ai";
var sourceFolder = new Folder(sourceFolderPath);
var tab = new Array();
runCheckTool();
//--------------------------------
function runCheckTool() {
var fileRef, docRef;
var contentInput = sourceFolder.getFiles(fileNameDefinition);
for (var i = 0; i < contentInput.length; i++) {
fileRef = null;
docRef = null;
try {
fileRef = new File(contentInput);
docRef = open(fileRef);
} catch(e) {
alert("# 1: " + e);
}
try{
checkLayers(docRef.layers);
} catch(e) {
alert("# 2: " + i + " " + e);
}
//docRef.close(SaveOptions.DONOTSAVECHANGES);
alert("end file index: " + i);
}
}
//--------------------------------
function checkLayers(relativeObjet) {
var name, obj;
for (var j = 0; j < relativeObjet.length; j++) {
checkLayers(relativeObjet.layers);
name = "";
obj = relativeObjet;
while (obj.parent.typename != "Document") {obj = obj.parent ; name = obj.name+ "/"+name;}
name = obj.parent.name+"/"+name+relativeObjet.name;
alert (name);
}
}
de elleere
Copy link to clipboard
Copied
I was running into this same problem. Hitting Tab first to hide the panels worked a little better, but what seems to work all the time is if I already have a document open when I run my script. Then it won't error. If I run my script when there are no documents open (my script adds a new document), it will almost always fail.