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

How to select open path objects not include no filled objects?

New Here ,
Jun 19, 2014 Jun 19, 2014

I use CS6.

I want to select open path objects, but not include no filled objects.

That means if these objects with open path and filled any color or gradient, I want to select them.

Now I can select objects with open path.

var doc = app.activeDocument;

doc.selection = null;

numClosed = 0;

for ( var i = 0; i < doc.pathItems.length; i++ )

{

    if ( ! doc.pathItems.closed )

    {

        doc.pathItems.selected = true;

        numClosed++;

    }

}

alert(numClosed + " paths open.");

But how to not include no filled shapes?

Anybody know?

Thank you.

TOPICS
Scripting
1.8K
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, 2014 Jun 19, 2014

Hi @jeen,

if you want to select only open paths with any fill color, you can replace this line:

if ( ! doc.pathItems.closed)

with this:

if ( ! doc.pathItems.closed && doc.pathItems.filled == true)

Have fun

Translate
Adobe
Community Expert ,
Jun 19, 2014 Jun 19, 2014

Hi @jeen,

if you want to select only open paths with any fill color, you can replace this line:

if ( ! doc.pathItems.closed)

with this:

if ( ! doc.pathItems.closed && doc.pathItems.filled == true)

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
New Here ,
Jun 19, 2014 Jun 19, 2014

Wow!~It works!

Thank you so 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
Explorer ,
Jan 11, 2023 Jan 11, 2023

Is anyone able to get this to work in modern CC apps? I keep getting an error that of no such element for line 6 "!doc.pathItems.closed"

My test file definitely contains broken paths.

var doc = app.activeDocument;
	doc.selection = null;
	numClosed = 0;

	for (var i = 0; i < doc.pathItems.length; i++) {
		if (!doc.pathItems.closed) {
			doc.pathItems.selected = true;
			numClosed++;
		}
	}
alert(numClosed + " paths open.");

 

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
Guide ,
Jan 11, 2023 Jan 11, 2023

Moving to the present forum caused loss of indices in loops. Change

		if (!doc.pathItems.closed) {
			doc.pathItems.selected = true;

to

		if (!doc.pathItems[i].closed) {
			doc.pathItems[i].selected = true;
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
Explorer ,
Jan 12, 2023 Jan 12, 2023
LATEST

This works perfectly. Thank you!

Revised and functioning properly in Illustrator CC 27.1.1:

var doc = app.activeDocument;
	doc.selection = null;
	numClosed = 0;

	for (var i = 0; i < doc.pathItems.length; i++) {
		if (!doc.pathItems[i].closed) {
			doc.pathItems[i].selected = true;
			numClosed++;
		}
	}
alert(numClosed + " paths open.");

 

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