Highlighted

Script for select sequentially all paths/compound paths by position at layer

Explorer ,
Oct 05, 2020

Copy link to clipboard

Copied

Hello

I am looking for a script for selecting sequentially all ungrouped paths or compound paths of the selected layer  by position 

e,g

Layer 1

   path4 

   path3

   compound 2

   path1

 

The script will select

path1,

after 1 second the

compoundpath2,

after  1 second the

path3 and

so on

It is possible?

 

path

 

Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

Hi,

Try following code

 

 

function main() {
    var doc = app.activeDocument;
    app.selection = null;
    var selectedLayer = doc.activeLayer;
    var _pageItems = selectedLayer.pageItems
    for (var i = 0; i < _pageItems.length; i++) {
        if (_pageItems[i].typename == 'PathItem' || _pageItems[i].typename == 'CompoundPathItem') {
            try {
                var item = _pageItems.getByName((i+1));
                item.selected = true;
            } catch (e) {
                try {
                    var item = _pageItems.getByName((i+1));
                    item.selected = true;
                } catch (e) {

                }
            }
        }
    }
}

main();

 

 

 

Above script assume, you have name items as 1, 2, 3 ,4 and so on.

Here is my question : Is your items are in sequence in layers always? If yes, above script can be modified but in case they are not in sequence but have name like 1, 2, 3 ,4 ,5 and so on then try above script. Make sure name should not be like <compond path> 3 as in your screenshot. 

 

NOTE : Also, make sure to select the layer before running the above script. In your case, select layer with name "cut"

 

TOPICS
Scripting

Views

59

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

Script for select sequentially all paths/compound paths by position at layer

Explorer ,
Oct 05, 2020

Copy link to clipboard

Copied

Hello

I am looking for a script for selecting sequentially all ungrouped paths or compound paths of the selected layer  by position 

e,g

Layer 1

   path4 

   path3

   compound 2

   path1

 

The script will select

path1,

after 1 second the

compoundpath2,

after  1 second the

path3 and

so on

It is possible?

 

path

 

Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

Hi,

Try following code

 

 

function main() {
    var doc = app.activeDocument;
    app.selection = null;
    var selectedLayer = doc.activeLayer;
    var _pageItems = selectedLayer.pageItems
    for (var i = 0; i < _pageItems.length; i++) {
        if (_pageItems[i].typename == 'PathItem' || _pageItems[i].typename == 'CompoundPathItem') {
            try {
                var item = _pageItems.getByName((i+1));
                item.selected = true;
            } catch (e) {
                try {
                    var item = _pageItems.getByName((i+1));
                    item.selected = true;
                } catch (e) {

                }
            }
        }
    }
}

main();

 

 

 

Above script assume, you have name items as 1, 2, 3 ,4 and so on.

Here is my question : Is your items are in sequence in layers always? If yes, above script can be modified but in case they are not in sequence but have name like 1, 2, 3 ,4 ,5 and so on then try above script. Make sure name should not be like <compond path> 3 as in your screenshot. 

 

NOTE : Also, make sure to select the layer before running the above script. In your case, select layer with name "cut"

 

TOPICS
Scripting

Views

60

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
Oct 05, 2020 0
Adobe Community Professional ,
Oct 05, 2020

Copy link to clipboard

Copied

Hi,

Try following code

 

 

function main() {
    var doc = app.activeDocument;
    app.selection = null;
    var selectedLayer = doc.activeLayer;
    var _pageItems = selectedLayer.pageItems
    for (var i = 0; i < _pageItems.length; i++) {
        if (_pageItems[i].typename == 'PathItem' || _pageItems[i].typename == 'CompoundPathItem') {
            try {
                var item = _pageItems.getByName((i+1));
                item.selected = true;
            } catch (e) {
                try {
                    var item = _pageItems.getByName((i+1));
                    item.selected = true;
                } catch (e) {

                }
            }
        }
    }
}

main();

 

 

 

Above script assume, you have name items as 1, 2, 3 ,4 and so on.

Here is my question : Is your items are in sequence in layers always? If yes, above script can be modified but in case they are not in sequence but have name like 1, 2, 3 ,4 ,5 and so on then try above script. Make sure name should not be like <compond path> 3 as in your screenshot. 

 

NOTE : Also, make sure to select the layer before running the above script. In your case, select layer with name "cut"

 

Best regards

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
Reply
Loading...
Oct 05, 2020 1
siomosp LATEST
Explorer ,
Oct 24, 2020

Copy link to clipboard

Copied

Hello,

it is perfect for my needs, thank you

Best regards

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
Reply
Loading...
Oct 24, 2020 1
Resources