Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

Finding pathItems that have no fill and no stroke

$
0
0

Hey Everyone,

 

So here's what I wrote to try and find and delete all pathItems within a document that lack a fill and lack a stroke.

 

var doc = app.activeDocument;

for (i=0; doc.pathItems.length>i;i++) {       alert(doc.pathItems[i].name + " " + doc.pathItems[i].fillColor.name)    alert(doc.pathItems[i].name + " "  + doc.pathItems[i].strokeColor.name)           if (doc.pathItems[i].fillColor.name == 'undefined' && doc.pathItems[i].strokeColor.name == 'undefined') {            alert("FOUND IT!")            doc.pathItems[i].remove()            }       }

 

Then I tried this since it's typename is [GrayColor]

 

 

var doc = app.activeDocument;

for (i=0; doc.pathItems.length>i;i++) {       alert(doc.pathItems[i].name + " " + doc.pathItems[i].fillColor.name)    alert(doc.pathItems[i].name + " "  + doc.pathItems[i].strokeColor.name)           if (doc.pathItems[i].fillColor.gray == 0 && doc.pathItems[i].strokeColor.gray == 0) {            alert("FOUND IT!")            doc.pathItems[i].remove()            }       }

 

But alas, neither seems to do the trick, the first one makes sense why it wouldnt work since it says that the color is "undefined" but it isnt a string called "undefined." So I'm not sure how to go about this at all now.

Any suggestions?


Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>