Skip to main content
Inspiring
September 20, 2024
Answered

Unpredictable active page

  • September 20, 2024
  • 2 replies
  • 3994 views

I'm working on a document that's a bit different from conventional, it's a storyboard.
So there are multiple pages on a single spread for each row of the storyboard.
The issue I'm running into, is that the active page is somewhat unpredictable.
I'm creating a function to add a panel (essentially a page) via script, because I need it to set up some specific elements and connect the text directly and so on... The problem, is that unless I'm fully zoomed in on a page, and even if I double-click, the current active page is sort of random. It tends to be the one that is in the center of the page.

Has anybody run into a similar issue or has a workaround? 

This topic has been closed for replies.
Correct answer Robert at ID-Tasker

I'm not sure I understand what you mean.
If I use the property "activePage", it doesn't give me the page that was last double-clicked, worked on, or clicked. It seems to be taking it from the space in the screen. That's the issue I have. 


In your video, you are selecting an object on the page - the you click Active Page button - you can get parent page of the selected object - the one you want to be "active" - from the selection.

 

2 replies

Inspiring
September 23, 2024

Just as an update to this, I used the selected item parent workaround. Thanks it solved it.


Things related to the spreads and positioning of the new page I'm going to continue on the other thread to avoid confusion. But to clarify in case someone reads it here: 

  1. The issue was trying to add a page somewhere in a spread and keep the document with 5 pages spreads, so it would have to cascade any exceeding pages down to next pages like it does with two facing pages. My current solution was to create a function that just rearranges all the spreads. Basically we add pages in spreads wherever we want and when we're done we hit the 'rearrange pages' button. It works, but it's not as elegant as natively having inDesign just doing it directly, which is probably faster even.
  2. The shuffling issue I had come across and solved it by hard coding the needed states during script execution and placing them back to where they were in the end of it.
rob day
Community Expert
Community Expert
September 23, 2024

Hi @Renan Barros  & @Robert at ID-Tasker , I found the code I’ve used for spread shuffling—I was looking in documentPreferences, but a spread also has an .allowPageShuffle property, which can be set to false. So this unchecks allow Selected Spread to Shuffle for the targeted spread and works:

var spd = app.activeDocument.spreads
//add pages to spread 2
addPagestoSpread(8,spd[1])


/**
* Add Pages to a spread
* @ param number of pages to add 
* @ param the spread to target 
* @ return void 
*/
function addPagestoSpread(n,s){
    app.activeDocument.documentPreferences.properties = {allowPageShuffle:false};
    //don’t allow the spread we are adding pages to shuffle
    s.allowPageShuffle = false;
    for (var i = 0; i < n; i++){
        app.activeDocument.pages.add(LocationOptions.AFTER, s);
    };   
}
Inspiring
September 23, 2024

That's the property I also used in my "add panel" script, the result is that the spread goes over "limit" being that my chosen limit, and that's why I ended up needing a function to rearrange things.

Robert at ID-Tasker
Legend
September 20, 2024
Inspiring
September 20, 2024

That's what I'm using that's giving me unpredictable results. I've attached a video.

Robert at ID-Tasker
Legend
September 20, 2024

Then get "activePage" - the one you want to be "active" - from the selection.