3 Replies Latest reply on Jan 10, 2014 1:20 PM by Prails.deisgn

    Finding pathItems that have no fill and no stroke

    Prails.deisgn Level 1

      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?