17 Replies Latest reply on Aug 27, 2016 7:49 PM by Silly-V

    Why illustrator allowed pathItem store error msg?

    JosephWang

      So this happen, I cycle through my artwork, compare their typename ono by one, and my script keep crushing.

      Turns out there is often one or two pathItem's object tree property completely lose their mind.

      No property, but error msg like this image, and this happens so often.

        • 1. Re: Why illustrator allowed pathItem store error msg?
          tpk1982 Level 4

          not sure why you used -1 in the for loop

           

          try

           

          for(i=0; i<targetGroup.pageItems.length; i++){

          • 2. Re: Why illustrator allowed pathItem store error msg?
            JosephWang Level 1

            Hi, thanks for reply, your code is same as mine

            • Mine

                 for(i=0; i<=targetGroup.pageItems.length - 1; i++){

            • Yours

                 for(i=0; i<targetGroup.pageItems.length; i++){

             

            both run the same times

            • 3. Re: Why illustrator allowed pathItem store error msg?
              tpk1982 Level 4

              agree.. but did you tried with my coding?

              • 4. Re: Why illustrator allowed pathItem store error msg?
                zertle Level 2

                I have run into that same error too.  Unfortunately I still don't know what causes it.  Some ways to fix the problem that I've found are to select all, cut, and paste then try running the script again. This can be automated:

                 

                var done = false;
                var firstTry = false;
                
                while( !done ) {
                  try {
                    if( !firstTry ) {
                       app.activeDocument.selectObjectsOnActiveArtboard();
                       app.cut();
                       app.paste();
                    }
                  
                    /* CODE TO PROCESS GROUPS */
                     
                    done = true;
                  }
                  catch(err) {
                    firstTry = false;
                  }
                }
                

                 

                This would all be inside of your function.  You could also add code to auto quit after 5 or so tries, just add a 'count' variable.

                 

                Other fixes I have found are closing and reopening the file or restarting Illustrator.  Sorry I don't have a better answer.

                • 6. Re: Why illustrator allowed pathItem store error msg?
                  Silly-V Adobe Community Professional

                  What AI version is this still happening on?

                  • 7. Re: Why illustrator allowed pathItem store error msg?
                    zertle Level 2

                    I'm running CC 19.2.0 (64-bit) on Windows 7.

                     

                    This is the error I get every now and then. curItem is just a GroupItem object but all of it's properties are undefined, and then once I reopen, they are all fine and accessible again.

                     

                    error_1_cropped.jpgerror_2_cropped.jpg

                     

                    It's really inconsistent, if I simply reopen the file or cut and paste everything, the error goes away. 

                    • 8. Re: Why illustrator allowed pathItem store error msg?
                      JosephWang Level 1

                      Hi, I ran into the problem on 2015.3

                      • 9. Re: Why illustrator allowed pathItem store error msg?
                        Silly-V Adobe Community Professional

                        Can you please post a working piece of your code that an Adobe person can help work with and debug?

                        • 10. Re: Why illustrator allowed pathItem store error msg?
                          JosephWang Level 1
                          
                          main();
                          
                          
                          function main(){
                              if (app.documents.length > 0) {
                                  var docRef = app.activeDocument;
                                  var selectedObjects = docRef.selection;
                          
                          
                                  if (selectedObjects.length > 0) {
                                      processArrayItem(selectedObjects);
                          
                          
                                  } else {
                                      //do nothing
                                  }
                              } else {
                                  alert("there are no open documents");
                              }
                          }
                          
                          
                          function processArrayItem(targetArray){
                              for (var i = 0; i <= targetArray.length - 1; i++) {
                                  if(targetArray[i].typename == "CompoundPathItem") {
                                      //do nothing
                          
                          
                                  } else if(targetArray[i].typename == "GroupItem") {
                                      //cycle through the group
                                      processGroupItem(targetArray[i]);
                                  } else {
                                      if(targetArray[i].filled == false) {
                                          // do nothing
                          
                          
                                      } else if(targetArray[i].fillColor.typename == "GradientColor") {
                                          // do nothing
                          
                          
                                      } else if(targetArray[i].fillColor.typename == "PatternColor") {
                                          // do nothing
                          
                          
                                      } else if(targetArray[i].fillColor.typename == "SpotColor") {
                                          // do nothing
                          
                          
                                      } else if(targetArray[i].fillColor.typename == "GrayColor") {
                                          // do nothing
                          
                          
                                      } else {
                                          changeSolidColorToGradient(targetArray[i]);
                                      }
                                  }
                              }
                          }
                          
                          
                          function processGroupItem(targetGroup){
                              for (var i = 0; i <= targetGroup.pageItems.length - 1; i++) {
                                  if(targetGroup.pageItems[i].typename == "CompoundPathItem") {
                                      //do nothing
                          
                          
                                  } else if(targetGroup.pageItems[i].typename == "GroupItem") {
                                      //cycle through the group
                                      processGroupItem(targetGroup.pageItems[i]);
                                  } else {
                                      if(targetGroup.pageItems[i].filled == false) {
                                          // do nothing
                          
                          
                                      } else if(targetGroup.pageItems[i].fillColor.typename == "GradientColor") {
                                          // do nothing
                          
                          
                                      } else if(targetGroup.pageItems[i].fillColor.typename == "PatternColor") {
                                          // do nothing
                          
                          
                                      } else if(targetGroup.pageItems[i].fillColor.typename == "SpotColor") {
                                          // do nothing
                          
                          
                                      } else if(targetGroup.pageItems[i].fillColor.typename == "GrayColor") {
                                          // do nothing
                          
                          
                                      } else {
                                          changeSolidColorToGradient(targetGroup.pageItems[i]);
                                      }
                                  }
                              }
                          }
                          
                          
                          function changeSolidColorToGradient(targetPathItem){
                              var originalColor = targetPathItem.fillColor;
                              var myGradientAngle = -60;
                              var startColor = new RGBColor();
                              var endColor = new RGBColor();
                              var darkenColor;
                              var finalColor = new GradientColor();
                              var finalGradient = app.activeDocument.gradients.add();
                          
                          
                              startColor.red = originalColor.red;
                              startColor.green = originalColor.green;
                              startColor.blue = originalColor.blue;
                              darkenColor = RGBtoHSV(originalColor.red, originalColor.green, originalColor.blue);
                              darkenColor = HSVtoRGB(darkenColor.h, darkenColor.s, darkenColor.v*0.8);
                              endColor.red = darkenColor.r;
                              endColor.green = darkenColor.g;
                              endColor.blue = darkenColor.b;
                          
                          
                              finalGradient.type = GradientType.LINEAR;
                              finalGradient.gradientStops[0].color = startColor;
                              finalGradient.gradientStops[0].rampPoint = 50;
                              finalGradient.gradientStops[1].color = endColor;
                          
                          
                              finalColor.gradient = finalGradient;
                          
                          
                              targetPathItem.fillColor = finalColor;
                              targetPathItem.rotate(myGradientAngle, false, false, true, false, Transformation.CENTER);
                          }
                          
                          
                          function HSVtoRGB(h, s, v) {
                              var r, g, b, i, f, p, q, t;
                              if (arguments.length === 1) {
                                  s = h.s, v = h.v, h = h.h;
                              }
                              i = Math.floor(h * 6);
                              f = h * 6 - i;
                              p = v * (1 - s);
                              q = v * (1 - f * s);
                              t = v * (1 - (1 - f) * s);
                              switch (i % 6) {
                                  case 0: r = v, g = t, b = p; break;
                                  case 1: r = q, g = v, b = p; break;
                                  case 2: r = p, g = v, b = t; break;
                                  case 3: r = p, g = q, b = v; break;
                                  case 4: r = t, g = p, b = v; break;
                                  case 5: r = v, g = p, b = q; break;
                              }
                              return {
                                  r: Math.round(r * 255),
                                  g: Math.round(g * 255),
                                  b: Math.round(b * 255)
                              };
                          }
                          
                          
                          function RGBtoHSV(r, g, b) {
                              if (arguments.length === 1) {
                                  g = r.g, b = r.b, r = r.r;
                              }
                              var max = Math.max(r, g, b), min = Math.min(r, g, b),
                                  d = max - min,
                                  h,
                                  s = (max === 0 ? 0 : d / max),
                                  v = max / 255;
                          
                          
                              switch (max) {
                                  case min: h = 0; break;
                                  case r: h = (g - b) + d * (g < b ? 6: 0); h /= 6 * d; break;
                                  case g: h = (b - r) + d * 2; h /= 6 * d; break;
                                  case b: h = (r - g) + d * 4; h /= 6 * d; break;
                              }
                          
                          
                              return {
                                  h: h,
                                  s: s,
                                  v: v
                              };
                          }
                          
                          • 11. Re: Why illustrator allowed pathItem store error msg?
                            Silly-V Adobe Community Professional

                            Thank you, I will pass this along!

                            • 12. Re: Why illustrator allowed pathItem store error msg?
                              Silly-V Adobe Community Professional

                              JosephWang - they appear to have done a test with your script but have been unable to reproduce the error during that test.

                              Are you also on Windows with CC2015.3 ?

                              zertle  can you also provide a snippet where you encounter this?

                              • 13. Re: Why illustrator allowed pathItem store error msg?
                                JosephWang Level 1

                                Hi, thanks for reply.

                                Yes, I'm on Windows with CC2015.3.

                                I think it's a rare bug, maybe run 20, 30 times to find the error, or even you never find the error.

                                Or specific Ai file, too many factors.  XDDD

                                • 14. Re: Why illustrator allowed pathItem store error msg?
                                  zertle Level 2

                                  I think it was something along these lines that would cause problems

                                   

                                  function temp() {
                                    var colorA = new RGBColor();
                                    colorA.red = 255;
                                    colorA.green = 0;
                                    color.blue = 0;
                                  
                                    var doc = app.activeDocument;
                                    var paths = doc.pathItems;
                                    for( var i = 0, ii = paths.length; i < ii; i++ ) {
                                      var curPath = paths[i];
                                      if( curPath.layer.visible && !curPath.layer.locked ) {
                                            curPath.fillColor = colorA;
                                      }
                                    }
                                  }
                                  
                                  temp();
                                  

                                   

                                  Something like this would infrequently produce an error because all of curPath's properties would be undefined, like the screenshot I posted earlier.  Unfortunately I don't have a file where this would happen consistently because reopening the file would often fix the error.

                                  • 15. Re: Why illustrator allowed pathItem store error msg?
                                    Silly-V Adobe Community Professional

                                    I despise this error, one of my clients has just reported one of these to me.

                                    Unfortunately it is probably happening in the middle of some complex task and copying/pasting may not even be a possible solution in their case.

                                    1 person found this helpful
                                    • 16. Re: Why illustrator allowed pathItem store error msg?
                                      Silly-V Adobe Community Professional

                                      I found this site and it has some interesting information:

                                      http://exportkit.com/answers/why-do-i-see-parm-error-in-illustrator

                                       

                                      This is why Illustrator crashes, it is a persistent system and it throws a core error. This causes the DOM to ”crash” and without a kill-recreate, its impossible to re-load the DOM without restarting Illustrator.
                                      1 person found this helpful
                                      • 17. Re: Why illustrator allowed pathItem store error msg?
                                        Silly-V Adobe Community Professional

                                        Hey guys,

                                         

                                        I have reason to believe that this error happens with some relationship to compoundPathItems.

                                        I have a file with many compoundPathItems, I run a simple script to manipulate the document and cycle through the compoundPathItems - everything works fine the first time. After that, if I close the document, or revert, and open it back up - the error always comes.

                                        The only way to solve was to restart Illustrator and make sure not to revert or close the file without saving and opening it again.

                                        Interestingly, saving the file as a new file with a different name, then opening the original file for re-processing does not yield the error.

                                        1 person found this helpful