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

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

Engaged ,
Oct 05, 2020 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

586

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 , Oct 05, 2020 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 {
...

Votes

Translate

Translate
Adobe
Community Expert ,
Oct 05, 2020 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

Votes

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
Engaged ,
Oct 24, 2020 Oct 24, 2020

Copy link to clipboard

Copied

LATEST

Hello,

it is perfect for my needs, thank you

Best regards

Votes

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