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

Finding pathItems that have no fill and no stroke

Participant ,
Jan 10, 2014 Jan 10, 2014

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?

TOPICS
Scripting

Views

870

Translate

Translate

Report

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);

}

Votes

Translate

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

Copy link to clipboard

Copied

For me this works:

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

  alert("Found "+pathItem);

}

Votes

Translate

Translate

Report

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

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--){

}

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

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