Copy link to clipboard
Copied
I'm so sick of these errors,
never had an issue before CC
anyone know what is causing these errors?
have been using this script all day and now it bugs out on me.
full script is below:
var doc = app.activeDocument;
var sel = doc.selection;
var TOmm = 2.83466796875;
Dim(sel);
function Dim(objs) {
for (var i=objs.length-1;i>=0;i--) { // loop through your collection of objects
var bounds = objs.visibleBounds; // Get visibal bounds, which are only visable bounds in some cases...
var b1 = bounds[0] /TOmm;
var b2 = bounds[1] /TOmm;
var b3 = bounds[2] /TOmm;
var b4 = bounds[3] /TOmm;
var W = Math.abs(b3-b1).toFixed(1);
var H = Math.abs(b4-b2).toFixed(1);
var txt = doc.textFrames.add(); // Create the text frame
txt.contents = "Size: "+ H + " x " +W + " mm W"; // Adds contents to frame
txt.position = [objs.left,objs.top - objs.height - 20]; // Positions the frame
};
};
Am I missing something in the quality of the Code?
Copy link to clipboard
Copied
I wonder what kinds of objects are in the selection, and if it could have anything to do with how Illustrator will allow things inside a selection which are not visible? (this happens rarely, but I have seen it)
Copy link to clipboard
Copied
It's not to do with the Selection.
once it starts throwing the error it will do so even with a simple rectangle.
Restart illustrator and its fine again for an indeterminate amount of time.
Some times I will go days without seeing it.
At other times it hits me many times a day.
Copy link to clipboard
Copied
Hmm, so are you by any chance shuffling between documents? ![]()
By the way, do you ensure that all the ones you run are in a closure?
Okay, I know as much about these as the next guy a few years in the game, but I can tell you of some crazy situations where I have encountered this error which would be seemingly unreasonable.
1) variables referring to page items between different documents. Sad, but true.
2) creating outlines from a text frame, and trying to work on compound paths which are produced. Some come out bad (contained pathItem is Object is Invalid, What??), some don't, so I eventually just made it do try-catch to repeat my process until it worked.
3) Document spot colors in a batch process, where some documents would open up and for no reason at all, some of the spot colors' properties would be invalid, leading to this error. I made it try-catch close document, open back up, until it worked.
I truly feel you pain, if that helps any. ![]()
Copy link to clipboard
Copied
once it errors, it will error on everything.
until illi is restarted.
then it will work on everything.
it just annoying and breaks my workflow.
guessing its some memory leak in the JS engine, but what do I know???
maybe I should flush the variables after using them?
Copy link to clipboard
Copied
when it happened yesterday arvo I only had the 1 doc open...
Copy link to clipboard
Copied
Well, are all of your scripts wrapped in their own function(){} ?
Hmm if not, it could be something to do with that, but yes, this is blind leading the blind to the max!
However, if we do not bring all this up, it'll never get solved!
Copy link to clipboard
Copied
some are some aren't.
I would be worried if that would cause issues!
Copy link to clipboard
Copied
Hm, not sure if that's anything to do with this, but I always wrap mine, and even though still get issues I described above, it can't hurt, right?
Copy link to clipboard
Copied
Some times I will go days without seeing it.
do you ever shut down Illustrator?
do your scripts run like a million times before restarting illustrator?
all scripts run in a single engine, and all variables are persistent until the engine is destroyed at restart, the engine saturates and crashes.
from the guide
Scripts that create, save, and close many Illustrator files should periodically quit and relaunch
Illustrator. The recommended maximum number of files to process before quitting and relaunching
Illustrator is:
Windows 500 files
Mac OS 1000 files
if you get the error in a fresh Illustrator session, then I have no idea.
Copy link to clipboard
Copied
Granted I have an aversion to restarting Illustrator, my computer, or anything, unless I really have to.
My PC goes in to a hybrid Sleep so Startup in the morning maxes out around 10 seconds.
and thanks to Scripts not being persistent in actions.
and nagging little things like "Preserve Black and White" in the "Recolor Artwork" panel also not being persistent on restart.
these combine to make restarting illustrator Painful as well.
with CS6 and previous versions I would go a week, Monday to Friday without restarting My PC, or illustrator.
and at times top a month of up time. no issues.
CC+ and I can just make it through a day if I'm lucky, most often I'm not so lucky.
The script mentioned above has worked with me for many years now, among others. and has not changed.
and although it was throwing an error other scripts would work fine...
I'm sure you are right, it's just annoying that it only started giving me grief since the move to CC.
wish there was a way to: purge all variables / restart the engine / even I had to purge each variable before script exit I may be happy
Copy link to clipboard
Copied
give it a try, make all variables = null to see if it helps.
on the other hand, your script could be perfectly fine and CC may be the cause of the error, it wouldn't be the first thing that gets broken with a version "update"
Copy link to clipboard
Copied
no resolution at all on this???
Adobe is awfully disappointing since CC came out... and it seems that every "update" things get progressively worse. Not even just with regards to scripting.. In CC 2015 we've had some issues with live text having jacked up anchor points where they don't belong and missing anchor points where they do belong resulting in pie shaped pieces cut out of the stroked appearance of certain letters. I've also seen strokes that have been expanded into compound path fills have anchor points go missing (see screenshot).
When is adobe going to get their act together and actually start responding to the professional community about this stuff?!?!?! frustrating as hell.
Copy link to clipboard
Copied
CarlosCanto wrote:
from the guide
Scripts that create, save, and close many Illustrator files should periodically quit and relaunch
Illustrator. The recommended maximum number of files to process before quitting and relaunching
Illustrator is:
Windows 500 files
Mac OS 1000 files
if you get the error in a fresh Illustrator session, then I have no idea.
Creative Cloud also has autosave every two minutes set by default! To change this go to Edit < Preferences < File Handling & Clipboard
Uncheck the first box.
I turned that off as well, not sure if that made a difference but can't hurt.
Copy link to clipboard
Copied
I recently "upgraded" to creative cloud so I am going through these issues currently. So far as possible solutions other than having to restart Illustrator I got from reading threads:
Please let me know if I am missing other solutions and I will come back here if I have any success. Thanks everyone!
Copy link to clipboard
Copied
I used to declare variables in loops and have stopped maybe 2 years ago, not sure if this helped. Now I put them all up into the top and initialize them below.
Before:
for(var i=0; i<x.length; i++){
var item = x;
};
After:
var item;
for(var i=0; i<x.length; i++){
item = x;
};
Let me know if it helps!
Copy link to clipboard
Copied
The only thing i've found that prevents the MRAP/PARM errors as much as possible is to avoid opening/closing files in between running scripts. If you have a script you want to run on several files, open all of them at once (or at least some of them.. i've gotten away with up to 50) and then run the script on each one and then close them when you're done or save/close them with the script.. so you can batch them with something like:
while(app.documents.length > 0)
{
//do something
app.activeDocument.close(SaveOptions.SAVECHANGES);
}
It is tedious, but i've identified the opening and closing of files to be the number one cause of these errors.
Good luck, man.
Copy link to clipboard
Copied
Hi
I have found that wrapping each scripts in a named function solves these errors.
This is documented by adobe somewhere (Google it for yourselves)
I used to get the errors a very lot but since doing the wrapping can't remember getting them.
Wrapping them with anonymous functions does not solve the problem.
Missing out vars can mess things up even when wrapped
Silly-V do you wrap yours scripts in name or anonymous functions?
Hope this helps someone
Trevor
Copy link to clipboard
Copied
I always wrap mine in a named function.
#target illustrator
function test(){
};
test();
^^^ I have this actually set as a hotstring on all my various workstations.
However, it still does not solve the issue in some situation. Closing the documents in a batch causes it as well as other not-easily-reproducible things such as when using UI's Undo after running a script to undo its effects and then re-running it. Weird stuff like that.
Copy link to clipboard
Copied
Has anyone messed with not using the "main" engine? I assume the main engine is what Illustrator defaults to if not specified. Would just using the "session" or "transient" engine make a difference when it comes to freeing memory assuming that is the issue? Having trouble finding documentation about how the engines all work. I have wrapped my scripts in functions and I am still getting errors.
Copy link to clipboard
Copied
I don't think you can change the engine on Illustrator by script. (Unlike InDesign)
Maybe you can with c++ (I doubt it) but Ai scripting all goes through BridgeTalk and is AFAIK allocated only one engine.
Copy link to clipboard
Copied
I do believe you are correct Trevor. ESTK only gives one option for the engine in illustrator and i've never heard of an override.
Copy link to clipboard
Copied
I just tried to do #targetengine "session" and it crashes the ESTK!
Copy link to clipboard
Copied
I just tried, it just gave the error message
Cannot execute script in target engine 'session'!
(#57) Engine 'session' does not exists!
Copy link to clipboard
Copied
Weird, I had an Illustrator cs6 script that used session for a bridgetalk. Now I am getting an error as well.
Looks like transient is working however, did session just change to transient for CC 2017?
#targetengine "transient"
Find more inspiration, events, and resources on the new Adobe Community
Explore Now