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

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

New Here ,
Jun 19, 2014 Jun 19, 2014

Copy link to clipboard

Copied

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

Views

1.4K

Likes

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

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

Likes

Translate

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

Copy link to clipboard

Copied

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

Likes

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

Copy link to clipboard

Copied

Wow!~It works!

Thank you so much!

Likes

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

Copy link to clipboard

Copied

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

 

Likes

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

Copy link to clipboard

Copied

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;

Likes

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
Community Beginner ,
Jan 12, 2023 Jan 12, 2023

Copy link to clipboard

Copied

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

 

Likes

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