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

Help understanding page bounds so they can automatically adjust to selected page? Or...spread??

Explorer ,
Jul 16, 2023 Jul 16, 2023

I have a script for generating guides based on an array

 

var pagey1 = app.activeWindow.activePage.bounds[0];
var pagex1 = app.activeWindow.activePage.bounds[1];
var pagey2 = app.activeWindow.activePage.bounds[2];
var pagex2 = app.activeWindow.activePage.bounds[3];


for (var i = 0; i < 20; ++i) {
    app.activeWindow.activePage.guides.add({name:"Blah"+i, location: (pagex2-pagex1)*Number(fractalSubdivisions[i])+pagex1, orientation: HorizontalOrVertical.VERTICAL});
}
 
And this is really  tripping me up because I know there's a simple formula or command that does what I want to do, but I have no clue how to do it.
 
So, I'm trying to draw guides on *whichever* page *happens* to be *actively selected*.
Now, the .bounds[...] command returns x1,y1,x2,y2. What is x1 and y1 and x2 and y2 in this case for a two page spread? If someone can explain that, perhaps I can work this out.

Right now, the problem with the script is that it doesn't distinguish between the first page of a two-page spread and the second page of a two-page spread, and I have no clue why.

I thought x1 was the upper-right corner or origin of a given actively selected page. If that were true, that would solve this right away, because I could select page1 of a spread and draw the guides on the correct page, or alternatively, select page 2 and draw the guides on page 2 because each guide would be offset to the right by page2's origin.

But alas, this appears not to be the case. 
TOPICS
Scripting
538
Translate
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 ,
Jul 16, 2023 Jul 16, 2023

Bounds of the Page are the same as GeometricBounds for objects:

[0,1,2,3] 

[top, left, bottom, right]

 

So width will be 3-1 and height 2-0.

 

Thanks to Bounds - you don't need to care about (0,0) point and if it's per page or for the spread - AND when there are more than two pages per spread or if there are gaps in between or pages are shifted. 

 

And you shouldn't be opening so many new posts - when it's still the same "problem".

 

Translate
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
Explorer ,
Jul 16, 2023 Jul 16, 2023

Sorry but I really have absolutely no idea how to interpret what you wrote. Can you please spell out what's happening in much much much more detail to adjust what I have now? I really need much more detail, pretend I'm entirely inept with any kind of coding, don't assume at all in any remote way shape or form that I'm an expert. 

 

The idea that all I need is 3-1 to make this work appears incorrect. It does not successfully attenuate to the active page of a selected spread based on what you have written. 

Translate
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 ,
Jul 16, 2023 Jul 16, 2023

I'm not JS guy and example in VB will be even more confusing - and I'm responding from my phone - so please check your 2nd thread and Mark's answer. 

 

Translate
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
Explorer ,
Jul 16, 2023 Jul 16, 2023

An example using the coding I presented will be a lot less confusing than something completely random and different you make up. Can you fix my current code to do what I'm trying to get it to do?

Translate
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 ,
Jul 17, 2023 Jul 17, 2023
LATEST

I'm not JS guy - my example of code would be in VisualBasic - completely different programming language. 

 

Translate
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