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

How to select "next object below"?

Guest
Jun 20, 2011 Jun 20, 2011

Copy link to clipboard

Copied

Hi all,

I have selected group objects then How to select "next object below" frames using javascript in indesign cs3?

TOPICS
Scripting

Views

979

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
Contributor ,
Jun 20, 2011 Jun 20, 2011

Copy link to clipboard

Copied

Hi

I interpreted you request as this figure below.

It works for me IDCS3 OSX 10.6.7

groupobject ( pageitem A-E)

  ├pageitem A

  ├pageitem B

  ├pageitem C

  ├pageitem D

  ├pageitem E

1. Current selection is B and run script.

2. C is selected

3. And then, current selection is E and run script.

4. A is selected

// select a pageitem in group object

if (app.selection.length === 0) {exit();};

if (app.selection[0].parent.constructor.name !== 'Group') {exit()};

var current_sel = app.selection[0];

var current_id = current_sel.id;

var parent_group = current_sel.parent;

for (var i=0, iL=parent_group.pageItems.length; i < iL ; i++) {

     if (parent_group.pageItems.id === current_id) {// current object

          // select next object

          if (i+1 < iL) {

               parent_group.pageItems[i+1].select();

          }

          else { // if selected last object, select first object

               parent_group.pageItems[0].select();

          }

     };

};

thank you
mg.

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
LEGEND ,
Jun 20, 2011 Jun 20, 2011

Copy link to clipboard

Copied

LATEST

          // select next object

          if (i+1 < iL) {

             parent_group.pageItems[i+1].select();

          }

          else { // if selected last object, select first object

             parent_group.pageItems[0].select();

          }

Instead, just use the modulo (remainder) operator, % sign.:

parent_grouppageItems[(i+1)%iL].select()

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