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

Why illustrator allowed pathItem store error msg?

Explorer ,
Jul 20, 2016 Jul 20, 2016

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.

TOPICS
Scripting
1.8K
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

correct answers 1 Correct answer

Participant , Aug 08, 2016 Aug 08, 2016

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;

 

...
Translate
Adobe
Guide ,
Jul 22, 2016 Jul 22, 2016

not sure why you used -1 in the for loop

try

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

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
Explorer ,
Jul 22, 2016 Jul 22, 2016

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

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
Guide ,
Jul 22, 2016 Jul 22, 2016

agree.. but did you tried with my coding?

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
Participant ,
Aug 08, 2016 Aug 08, 2016

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.

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
Explorer ,
Aug 08, 2016 Aug 08, 2016

Awesome!

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
Valorous Hero ,
Aug 09, 2016 Aug 09, 2016

What AI version is this still happening on?

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
Participant ,
Aug 09, 2016 Aug 09, 2016

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. 

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
Explorer ,
Aug 09, 2016 Aug 09, 2016

Hi, I ran into the problem on 2015.3

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
Valorous Hero ,
Aug 12, 2016 Aug 12, 2016

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

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
Explorer ,
Aug 15, 2016 Aug 15, 2016

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.typename == "CompoundPathItem") {

            //do nothing

        } else if(targetArray.typename == "GroupItem") {

            //cycle through the group

            processGroupItem(targetArray);

        } else {

            if(targetArray.filled == false) {

                // do nothing

            } else if(targetArray.fillColor.typename == "GradientColor") {

                // do nothing

            } else if(targetArray.fillColor.typename == "PatternColor") {

                // do nothing

            } else if(targetArray.fillColor.typename == "SpotColor") {

                // do nothing

            } else if(targetArray.fillColor.typename == "GrayColor") {

                // do nothing

            } else {

                changeSolidColorToGradient(targetArray);

            }

        }

    }

}

function processGroupItem(targetGroup){

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

        if(targetGroup.pageItems.typename == "CompoundPathItem") {

            //do nothing

        } else if(targetGroup.pageItems.typename == "GroupItem") {

            //cycle through the group

            processGroupItem(targetGroup.pageItems);

        } else {

            if(targetGroup.pageItems.filled == false) {

                // do nothing

            } else if(targetGroup.pageItems.fillColor.typename == "GradientColor") {

                // do nothing

            } else if(targetGroup.pageItems.fillColor.typename == "PatternColor") {

                // do nothing

            } else if(targetGroup.pageItems.fillColor.typename == "SpotColor") {

                // do nothing

            } else if(targetGroup.pageItems.fillColor.typename == "GrayColor") {

                // do nothing

            } else {

                changeSolidColorToGradient(targetGroup.pageItems);

            }

        }

    }

}

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

    };

}

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
Valorous Hero ,
Aug 15, 2016 Aug 15, 2016

Thank you, I will pass this along!

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
Valorous Hero ,
Aug 17, 2016 Aug 17, 2016

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?

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
Explorer ,
Aug 17, 2016 Aug 17, 2016

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

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
Participant ,
Aug 18, 2016 Aug 18, 2016

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;

    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.

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
Valorous Hero ,
Aug 23, 2016 Aug 23, 2016

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.

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
Valorous Hero ,
Aug 23, 2016 Aug 23, 2016

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.
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
Valorous Hero ,
Aug 27, 2016 Aug 27, 2016
LATEST

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.

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