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.
1 Correct answer
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
Explore related tutorials & articles
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
Copy link to clipboard
Copied
Wow!~It works!
Thank you so much!
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.");
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;
Copy link to clipboard
Copied
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.");

