Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Selecting the Odd Pages Only and Assign Label to it

Enthusiast ,
Apr 17, 2021 Apr 17, 2021

Copy link to clipboard

Copied

Hi Experts, Please help me with the Code, i dont know what i missed!, it shouid select all Odd pages in the document and assign an Odd Label to it, but it doesnt work!.

 

 

(function () {
  var myDoc = app.activeDocument;
  var myPage = myDoc.pages;
  var myFrames = myDoc.textFrames;
    for (var i=0; i< myFrames.length ; i++) {
        if (myPage.side === PageSideOptions.LEFT_HAND) {
      myFrames[i].label ="odd";
    }
  }
}());

 

 

 Thanks in Advance

Best Regards

M.Hasanain

Best
M.Hasanain
TOPICS
Scripting

Views

173

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
community guidelines

correct answers 2 Correct answers

Enthusiast , Apr 17, 2021 Apr 17, 2021
Hi, You have a couple of problems. First page.side will only work if you have facing pages. More importantly, in the loop you need to address the page, not the page item. My question, why name the frames "odd" when a left hand page is even? Below is how I wrote it (including a counter to return the number of frames labeled): var success = testSide (); alert ("Total frames labeled: " + success); function testSide () { var myCounter = 0; var myDoc = app.activeDocument; var myPage = myDoc.pages; ...

Likes

Translate

Translate
Adobe Community Professional , Apr 19, 2021 Apr 19, 2021
FWIW: Also discussed and solved in this thread: Assign Script Label to Odd Pages Trying to Exclude Text Frames in Master page https://community.adobe.com/t5/indesign/assign-script-label-to-odd-pages-trying-to-exclude-text-frames-in-master-page/m-p/11979418#M422765 Regards, Uwe Laubender ( ACP )

Likes

Translate

Translate
Enthusiast ,
Apr 17, 2021 Apr 17, 2021

Copy link to clipboard

Copied

Hi,
You have a couple of problems. First page.side will only work if you
have facing pages.
More importantly, in the loop you need to address the page, not the page item.
My question, why name the frames "odd" when a left hand page is even?
Below is how I wrote it (including a counter to return the number of
frames labeled):

var success = testSide ();
alert ("Total frames labeled: " + success);

function testSide () {
var myCounter = 0;
var myDoc = app.activeDocument;
var myPage = myDoc.pages;
var myFrames = myDoc.textFrames;
for (var i=0; i< myFrames.length ; i++) {
var myPage = myFrames[i].parentPage;
if (myPage.side == PageSideOptions.LEFT_HAND) {
myCounter ++;
myFrames[i].label ="odd";
}
}
return myCounter;
}

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
community guidelines
Enthusiast ,
Apr 18, 2021 Apr 18, 2021

Copy link to clipboard

Copied

Thank you alot, Actually the reason of naming the left page (odd) is that document is Right to left Document Becuase i use InDesign ME Support Arabic and Hebrew and Both Languages Writtened from Right to Left(RTL Document), I'm Beginner in Programming JavaScript, Actually I Need your advice about InDesign DOM, Because i have Difficulties with Understanding How to Catch Porperties and Values in sequence in the JavaScript Code, I need a Road Map Guide (Some Rules) in Connecting the Chain of the Codes, in the Example (MyFrames) will equal :

MyFrames = app.activeDocument.textFrames (i Understand that in InDesign DOM) its important to follow the Hierarchy of Commands, But a lot of times i got lost! and confused, can you tell me how to Overcome this problem to be a better coder with InDesign JavaScript and Thank you a lot, I learend a lot today.

Best Regards

M.Hasanain

Best
M.Hasanain

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
community guidelines
Adobe Community Professional ,
Apr 19, 2021 Apr 19, 2021

Copy link to clipboard

Copied

FWIW: Also discussed and solved in this thread:

 

Assign Script Label to Odd Pages Trying to Exclude Text Frames in Master page

https://community.adobe.com/t5/indesign/assign-script-label-to-odd-pages-trying-to-exclude-text-fram...

 

Regards,
Uwe Laubender

( ACP )

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
community guidelines
Adobe Community Professional ,
May 05, 2021 May 05, 2021

Copy link to clipboard

Copied

LATEST

You could also assign a label to the page object itself.

This is even possible in the GUI with the Script Label panel, if pages are selected with the Page tool:

 

PageLabel-1.PNG

 

And if you ask for a specific value for textFrame.parentPage you could directly see if the text frame is left from the spine.

alert( app.selection[0].parentPage.label );

 

PageLabel-2.PNG

 

Note: parentPage will return null if the object is on the pasteboard.

 

Hm. The more I think about it…

If you test for side you only test for left or right from the spine. If a given page is an odd or even page is a bit fuzzy, it could be a matter of page naming and also important is the number of pages left or right from the spine. There could be up to 10 pages in one spread.

 

Regards,
Uwe Laubender

( ACP )

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
community guidelines