Skip to main content
Inspiring
January 14, 2011
Question

CS4 - paste() produces: an illustrator error occurred: 2('')

  • January 14, 2011
  • 1 reply
  • 2278 views

I am automating copy and paste between two open files in Illustrator.I'm not using CreateFromFile since that strips variable names and otherwise alters the imported pageitems and makes them useless.

For some systems users get an error when the past command is used in the script.

Not much to it, after selected groups on the first document are selected a copy statement is used, the active document is changed, and a paste statement is used. It normally works but only on some combinations of selections on some computers. Adding a redraw() after the target document is activated avoids the error on some computers but not all.

copy();
doc.activate();

redraw();

doc.activeLayer = layerOption;
paste();

An error occurs on the paste(); statement

an illustrator error occurred: 2('')

I've run directly from the ExtendScript toolkit editor and tried adding extra redraws() (to allow adobe to catch up to the scripting) all to no avail.

Any ideas on what I can try?

This topic has been closed for replies.

1 reply

Inspiring
February 9, 2011

Putting an "alert" statement after the copy stops the error. This happens on different pc's even windows 7 64 bit with better hardware. I also tried creating a separate scratch disk for Adobe which made no difference.

So, this avoids the error:

copy();
alert('Click OK to continue');
doc.activate();
doc.activeLayer = layerOption;
paste();

Is there a command that I can use in JavaScript with AI that will wait but won't stop all activity? I tried "redraw()" but that doesn't do the job.

This is extraordinarily annoying. There are lots of bugs in Adobe Illustrator CS4 with scripting that I've run into but Adobe never released a single patch to AI CS4. Not a one. If upgrading to CS5 was free that'd be one thing but with dozens of users upgrading will be a major expense.

Muppet_Mark-QAl63s
Inspiring
February 9, 2011

I find on numerous occasions an alert() is better than a redraw() at refreshing… I have not had this error thou yet…

Inspiring
February 9, 2011

I get the feeling that the scripted commands outpace the ability of AI to process them completely. I had originally thought redraw() would make the client wait to catch up but that doesn't seem to be the case.

Maybe if there was a DoEvents() or otherwise idling command available that could be put into a loop and not just freeze the app like an empty javascript loop would. I guess I could try putting redraw() in a loop but that would probably just generate more commands that would back up.

Another post here reported that setTimeout won't work with Adobe JavaScript but I guess I could try and see for myself. It might be easier to just run 2 scripts in a row. :-|