Hey all.
I've got a really perplexing issue here and I wish i had more information to give you about it..
Here's a little backstory. Probably unnecessary, so skip it if you like.
Last year, i wrote a sort of preflight script to ensure our files were ready for production. We use spot colors for 100% of our artwork to aid in color matching over long periods of time. The Ink colors are then controlled in our RIP software to account for printer wear and climate differences. However, the usage of spot colors creates an issue then with regards to pattern fills. Spot colors contained within pattern fills are not properly read by the RIP. The solution was to hide solid blocks of color behind the artwork so the colors would be read and converted properly. This presented a challenge on it's own in that when left up to the production artist, often times colors would be omitted, or incorrect colors would be added (namely, the color that signifies a cut line, therefore a nice neat square would be cut from the center of each piece...). So, to remove the human error factor and greatly increase the speed of performing this task, i decided to write some javascript to do it for us.
Anywho, that brings me to the problem. approximately 20% of the time, when trying to use javascript to loop through the swatches panel, i get "an illustrator error has occurred: 1346458189". After some investigation, i've noticed that on seemingly random occasions, ESTK seems unable to read the swatch or it's properties. As i step through the loop, i can see the names and all applicable properties of a particular swatch. Then i'll get to one swatch that will cause an error and the data browser, instead of showing "swatchVariable = [Swatch Name]' it will just say "swatchVariable = [Swatch]". And when i expand that variable, i only see two things listed under the variable. remove{} and typename = Illustrator error blah blah.
The truly troublesome part for me, is that if i copy the exact same artwork into a new file and run the same script again, most of the time, it works without a hitch. Can anybody explain why certain swatches (always different ones) will occasionally throw this type of error??
This isn't the script i talked about above (adding blocks of color), but it does essentially the same thing regarding looping the swatch panel and attempting to get the properties of each swatch and it throws the same types of errors with equal frequency... HELP!
function defaultSwatchDelete(){ var docRef = app.activeDocument; var swatches = docRef.swatches; var exterminate = []; var deleteSwatches =[ "White", "Black", "CMYK Red", "CMYK Yellow", "CMYK Green", "CMYK Cyan", "CMYK Blue", "CMYK Magenta", "C=15 M=100 Y=90 K=10", "C=0 M=90 Y=85 K=0", "C=0 M=80 Y=95 K=0", "C=0 M=50 Y=100 K=0", "C=0 M=35 Y=85 K=0", "C=5 M=0 Y=90 K=0", "C=20 M=0 Y=100 K=0", "C=50 M=0 Y=100 K=0", "C=75 M=0 Y=100 K=0", "C=85 M=10 Y=100 K=10", "C=90 M=30 Y=95 K=30", "C=75 M=0 Y=75 K=0", "C=80 M=10 Y=45 K=0", "C=70 M=15 Y=0 K=0", "C=85 M=50 Y=0 K=0", "C=100 M=95 Y=5 K=0", "C=100 M=100 Y=25 K=25", "C=75 M=100 Y=0 K=0", "C=50 M=100 Y=0 K=0", "C=35 M=100 Y=35 K=10", "C=10 M=100 Y=50 K=0", "C=0 M=95 Y=20 K=0", "C=25 M=25 Y=40 K=0", "C=40 M=45 Y=50 K=5", "C=50 M=50 Y=60 K=25", "C=55 M=60 Y=65 K=40", "C=25 M=40 Y=65 K=0", "C=30 M=50 Y=75 K=10", "C=35 M=60 Y=80 K=25", "C=40 M=65 Y=90 K=35", "C=40 M=70 Y=100 K=50", "C=50 M=70 Y=80 K=70", "White, Black", "Orange, Yellow", "Fading Sky", "Super Soft Black Vignette", "Foliage", "Pompadour", ] try{ var grayGroup = docRef.swatchGroups.getByName("Grays"); grayGroup.remove(); } catch(e){ } try{ var brightsGroup = docRef.swatchGroups.getByName("Brights"); brightsGroup.remove(); } catch(e){ } undesirable(); function undesirable(){ for (a=0; a<swatches.length; a++){ try{ var curSwatch = swatches[a]; if (curSwatch.name != "[Registration]" && curSwatch.name != "[None]"){ for(b=0; b< deleteSwatches.length; b++){ var dS = deleteSwatches[b]; if(curSwatch.name == dS){ exterminate.push(curSwatch); } } } } catch(e){ alert("Couldn't Get Swatch Info"); } } for (d=exterminate.length-1; d>-1; d--){ exterminate[d].remove(); } } } defaultSwatchDelete();