3 Replies Latest reply on Jun 22, 2015 3:10 AM by subieguy2

    No Stroke No Fill not recognizing

    subieguy2 Level 1

      Can someone tell me why my else if statement isn't working? I know I have 3 path items that have no fill and no stroke...

      #target illustrator
      var allDocs = app.documents;
      var doc = app.activeDocument;
      var allLayers = doc.layers;
      var allLines = doc.pathItems;
      var counter = 0;
      for (var i = 0; i < allLines.length; i++) {
          if (allLines[i].layer == "[Layer Tables]") {
              if (allLines[i].stroked == true) {
                  counter++;
                  allLines[i].remove();
              } else if (allLines[i].stroked == false && allLines[i].filled == false) {
                  counter++;
                  allLines[i].remove();
              }
          }
      }
      alert(counter + " items removed");
      

       

      Adobe Illustrator CS4 Windows 64 Bit JavaScript

        • 1. Re: No Stroke No Fill not recognizing
          pixxxel schubser Level 5

          Hi subieguy2,

          if I understand you right – you are on the wrong way.

          I think you want to find and remove on the layer [Layer Tables] all path items which are stroked – or which have no outline AND no filling.


          In this case you can try something like this:

          #target illustrator  
          //var allDocs = app.documents;  
          var aDoc = app.activeDocument;
          var counter = 0;
          try {
          var specLayer = aDoc.layers.getByName ("[Layer Tables]");
          var allSpecPI = specLayer.pathItems;
          var PI_len = allSpecPI.length;
          
          for (i = PI_len - 1; i > 0; i--) {
              if (allSpecPI[i].stroked == true) {
                   // only path items with filling and without stroke are remain
                  counter++;
                  allSpecPI[i].remove();
                  } else {
                      if (allSpecPI[i].stroked == false && allSpecPI[i].filled == false) {
                          counter++;
                          allSpecPI[i].remove();
                          }
                      }
                  }
              alert(counter + " items removed");
              }
          catch (e) {
              alert ("specific layer not found");
              }
          

           

           

          Have fun

           

          • 2. Re: No Stroke No Fill not recognizing
            CarlosCanto Adobe Community Professional & MVP

            your else if statement is ok, the problem is syntax in this line

             

            if (allLines[i].layer == "[Layer Tables]") {


            it should be

            if (allLines[i].layer.name == "Tables") {


            that will make your script work, but to make it work correctly follow pixxxel's script

            • 3. Re: No Stroke No Fill not recognizing
              subieguy2 Level 1

              That is exactly what I was trying to accomplish. Thank you both for your help and feedback!