Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Finding pathItems that have no fill and no stroke

Participant ,
Jan 10, 2014 Jan 10, 2014

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?

TOPICS
Scripting
960
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Jan 10, 2014 Jan 10, 2014

For me this works:

if(pathItem.filled==false && pathItem.stroked==false){

  alert("Found "+pathItem);

}

Translate
Adobe
Valorous Hero ,
Jan 10, 2014 Jan 10, 2014

For me this works:

if(pathItem.filled==false && pathItem.stroked==false){

  alert("Found "+pathItem);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 10, 2014 Jan 10, 2014

Also you're removing the items so it's better to go backwards:

for(var i=doc.pathItems.length-1; i>-1; i--){

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 10, 2014 Jan 10, 2014
LATEST

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines