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

No Stroke No Fill not recognizing

Engaged ,
Jun 19, 2015 Jun 19, 2015

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.layer == "[Layer Tables]") {

        if (allLines.stroked == true) {

            counter++;

            allLines.remove();

        } else if (allLines.stroked == false && allLines.filled == false) {

            counter++;

            allLines.remove();

        }

    }

}

alert(counter + " items removed");

Adobe Illustrator CS4 Windows 64 Bit JavaScript

TOPICS
Scripting
656
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

Community Expert , Jun 19, 2015 Jun 19, 2015

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_

...
Translate
Adobe
Community Expert ,
Jun 19, 2015 Jun 19, 2015

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.stroked == true) {

         // only path items with filling and without stroke are remain

        counter++;

        allSpecPI.remove();

        } else {

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

                counter++;

                allSpecPI.remove();

                }

            }

        }

    alert(counter + " items removed");

    }

catch (e) {

    alert ("specific layer not found");

    }

Have fun

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
Community Expert ,
Jun 21, 2015 Jun 21, 2015

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

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


it should be

if (allLines.layer.name == "Tables") {


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

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
Engaged ,
Jun 22, 2015 Jun 22, 2015
LATEST

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

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