Copy link to clipboard
Copied
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.name + " " + doc.pathItems.fillColor.name)
alert(doc.pathItems.name + " " + doc.pathItems.strokeColor.name)
if (doc.pathItems.fillColor.name == 'undefined' && doc.pathItems.strokeColor.name == 'undefined') {
alert("FOUND IT!")
doc.pathItems.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.name + " " + doc.pathItems.fillColor.name)
alert(doc.pathItems.name + " " + doc.pathItems.strokeColor.name)
if (doc.pathItems.fillColor.gray == 0 && doc.pathItems.strokeColor.gray == 0) {
alert("FOUND IT!")
doc.pathItems.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?
For me this works:
if(pathItem.filled==false && pathItem.stroked==false){
alert("Found "+pathItem);
}
Copy link to clipboard
Copied
For me this works:
if(pathItem.filled==false && pathItem.stroked==false){
alert("Found "+pathItem);
}
Copy link to clipboard
Copied
Also you're removing the items so it's better to go backwards:
for(var i=doc.pathItems.length-1; i>-1; i--){
}
Copy link to clipboard
Copied
Thank you, I wasn't familiar with "filled" and "stroked" but that makes so much sense. And yes you are 100% correct counting down avoids having it skip some.
Thank you very much!