Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Intermittent Javascript MRAP error

New Here ,
Oct 04, 2013 Oct 04, 2013

I have a for loop which moves all elements of an "Artwork" layer to a "working" layer so that I can edit the elemets without a chance of affecting the original layer:

for (var i=app.documents[0].layers['Artwork'].pageItems.length-1; i>=0; i--)

{

          try

          {

                    app.documents[0].layers['Artwork'].pageItems.duplicate(app.documents[0].layers['working'], ElementPlacement.PLACEATEND);

          }

          catch(e)

          {

                    alert(e);

          }

}

This seems to work fine for three or four documents, and then begins to return the following error:

Error: an Illustrator error occurred: 1346458189 ('MRAP')

Action on every document then returns this error, even ones on which it has previously worked. The only solution is to quit Illustrator and relaunch.

Am I missing something obvious?

Thanks in advance.

TOPICS
Scripting
3.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Advocate ,
Oct 04, 2013 Oct 04, 2013

Are you running this script via the Extended Script Toolkit application?

Or the error occurs even if you execute directlly from Illustrator (like a

normal user)?

Gustavo.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 04, 2013 Oct 04, 2013

This is executed directly from Illustrator (like a normal user).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 04, 2013 Oct 04, 2013

If you try:

#target illustrator

#targetengine main

var artwork = app.activeDocument.layers.getByName ("Artwork");

var items = artwork.pageItems;

var working = app.activeDocument.layers.getByName ("working");

for (var g=0 ; g<items.length ;  g++){

    try {

        items.duplicate(working, ElementPlacement.PLACEATEND);

    } catch(e){

        alert(e);

    };

};

Does it get the same error?

Which Illustrator version are you using? Which OS?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 04, 2013 Oct 04, 2013

The AI guide suggests wrapping your snytax inside of functions and calling them… to avoid these types of errors…

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2013 Oct 04, 2013

At first:

The code that Gustavo Del Vechio has sent is the better one.

Your code could also functionate, but there are many syntax errors:

for (var i=app.documents[0].layers['Artwork'].pageItems.length-1; i>=0; i--) // here you have defined the counter "i"

{

try

{

// here you use a undefined counter "r"

// here is a space inside

// if you loop backwards, you should use "PLACEATBEGINNING"

app.documents[0].layers['Artwork'].pageItems.duplicate(app.documen ts[0].layers['working'], ElementPlacement.PLACEATEND);

}

catch(e)

{

alert(e);

}

}

In this case your code functionate, too:

(But it is really better to use some variables for that)

for (var i=app.documents[0].layers['Artwork'].pageItems.length-1; i>=0; i--) {

    try {

        app.documents[0].layers['Artwork'].pageItems.duplicate(app.documents[0].layers['working'], ElementPlacement.PLACEATBEGINNING );

        }

    catch(e)

    {

        alert(e);

        }

    }

Have fun

---

Once again:

Why you used app.documents[0] ?

Do you work with more than one document at the same time?

--

Message was edited by: pixxxel schubser

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 04, 2013 Oct 04, 2013

Sorry, the code is actually contained within a function.

You're correct about the typeos, but it doesn't actually appear that way in the code.

I've tried PLACEATEND and PLACEATBEGINNING with similar results.

I used app.documents[0], app.activeDocument and variables to try to trace the problem. This one is the one I happened to copy.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2013 Oct 04, 2013

baktunatier wrote:

I have a for loop which moves all elements of an "Artwork" layer to a "working" layer so that I can edit the elemets without a chance of affecting the original layer:

for (var i=app.documents[0].layers['Artwork'].pageItems.length-1; i>=0; i--)

{

          try

          {

                    app.documents[0].layers['Artwork'].pageItems.duplicate(app.documen ts[0].layers['working'], ElementPlacement.PLACEATEND);

          }

          catch(e)

          {

                    alert(e);

          }

}

This seems to work fine for three or four documents, and then begins to return the following error:

Error: an Illustrator error occurred: 1346458189 ('MRAP')

Action on every document then returns this error, even ones on which it has previously worked. The only solution is to quit Illustrator and relaunch.

Am I missing something obvious?

Thanks in advance.

In my opinion the posted code snippet is not responsible for the described error. The code works for me in CS3 and now tested in CS5.

For another answer, there is too little information.

Sorry

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 04, 2013 Oct 04, 2013

I think that is correct, but just wanted input on whether there was something wrong with my loop. Thanks.

I'll try another approach.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 31, 2016 Mar 31, 2016
LATEST

Hello

Just for anyone who will google for the same problem

In my case (also was a huge batch processing with javascript)  I've found the solution by inserting a delay between each iteration:

$.sleep(3000);

Maybe even less ms delay will work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines