I'm attempting to build a preflight of sorts for my Illustrator workflow (since for some reason.. preflight in illustrator doesn't exist...).
Essentially i need to loop through the pathItems on each artboard looking for a specific spot color (first verifying that the spot color does NOT exist as a fill color in any of the artwork, then checking for the presence of any pathItem that contains the spot color as a stroke).
This seemed to be a really straightforward task, but it seems as though pathItems.fillColor or pathItems.strokeColor is not a valid property? That confuses me because it works to apply a color to a pathItem.. It seems to me if you can apply a color via pathItems.fillColor, you should also be able to create an if clause that determines whether pathItems.fillColor == (some color). However, while testing this in the simplest of documents wherein i know what the result of the if clause should be, it doesn't work. is there something I'm missing here about the property fillColor/strokeColor??
Here's the code I'm working with. Thanks, all.
#target Illustrator var docRef = app.activeDocument; var aB = docRef.artboards; var swatchList = docRef.swatches; var tC = swatchList.getByName("Thru-cut"); var tCCount = 0; //how many artboards/top level groups contain at least 1 Thru-cut stroke? var artLayers = docRef.layers; var groups = artLayers[0].groupItems; var aBtCCount = 0; // how many artboards have var aBnoTC = []; // which artboards/top level groups (by index) do not contain at least 1 Thru-cut stroke? for (a = 0; a < aB.length; a++){ aBtCCount = 0 var items = groups[a].pathItems; for (b = 0; b < items.length; b ++){ if (items[b].fillColor == swatchList.getByName("Thru-cut")){ alert("You have Thru-cut fills in your document!!"); break; } //end if // thru-cut is fill else if (items[b].strokeColor == swatchList.getByName("Thru-cut")){ tCCount++; break; } //end if // thru-cut is stroke else{ tCCount = 0; } //end else // set counter to 0 }//end for loop B // checking items on each artboard if(tCCount == 0){ aBnoTC.push(" " + a); }//end if // artboard has no cut line else{ aBtCCount++; }//end else // add to counter for total artboards w/ thru-cut alert(tCCount); }//end for loop A if (aBtCCount < aB.length){ alert("Artboard/s " + aBnoTC + " are missing Thru-cut lines"); }//end if // not enough cut lines