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

 

TOPICS
Scripting

Views

80

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

1 Correct Answer

Adobe Community Professional , Oct 05, 2020
Charu Rajput Adobe Community Professional , Oct 05, 2020
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 {...

Likes

Translate

Translate
Jump to answer Jump to answer
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
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
siomosp AUTHOR 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
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more