Copy link to clipboard
Copied
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.
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;
Copy link to clipboard
Copied
not sure why you used -1 in the for loop
try
for(i=0; i<targetGroup.pageItems.length; i++){
Copy link to clipboard
Copied
Hi, thanks for reply, your code is same as mine
for(i=0; i<=targetGroup.pageItems.length - 1; i++){
for(i=0; i<targetGroup.pageItems.length; i++){
both run the same times
Copy link to clipboard
Copied
agree.. but did you tried with my coding?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Awesome!
Copy link to clipboard
Copied
What AI version is this still happening on?
Copy link to clipboard
Copied
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.
It's really inconsistent, if I simply reopen the file or cut and paste everything, the error goes away.
Copy link to clipboard
Copied
Hi, I ran into the problem on 2015.3
Copy link to clipboard
Copied
Can you please post a working piece of your code that an Adobe person can help work with and debug?
Copy link to clipboard
Copied
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
};
}
Copy link to clipboard
Copied
Thank you, I will pass this along!
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now