Skip to main content
Known Participant
January 8, 2018
Answered

How do i specify which page to put the guides on?

  • January 8, 2018
  • 1 reply
  • 639 views

Hello all!

I am relatively new to scripting, and I am writing a script but need a little help with it. I created the script below, but don't know how to specify which page to put the guides on. Could somebody please give me a little guidance? I would like the script to automatically put the guides on the active page. Does that make sense? Below is my code. Thanks soo much!!

#target "InDesign"

var myDocument = app.activeDocument;

var myPage = myDocument.pages.item(0);

//Set the measurement units to inches.

myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;

myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;

//Create variables.

var myPageWidth = myDocument.documentPreferences.pageWidth;

var myPageHeight = myDocument.documentPreferences.pageHeight;

var mySecondVerticalGuideLocation = myPageWidth/1.6180339887;

var myFirstVerticalGuideLocation = myPageWidth-mySecondVerticalGuideLocation;

var mySecondHorizontalGuideLocation = myPageHeight/1.6180339887;

var myFirstHorizontalGuideLocation = myPageHeight-mySecondHorizontalGuideLocation;

with(myDocument.pages.item(0)){

//Place the two vertical guides.

    guides.add(undefined, {orientation:HorizontalOrVertical.vertical,

    location:(myPageWidth/1.6180339887)});

    guides.add(undefined, {orientation:HorizontalOrVertical.vertical,

    location:(myFirstVerticalGuideLocation)});

//Place the two horizontal guides.

    guides.add(undefined, {orientation:HorizontalOrVertical.horizontal,

    location:(myPageHeight/1.6180339887)});

    guides.add(undefined, {orientation:HorizontalOrVertical.horizontal,

    location:(myFirstHorizontalGuideLocation)});

}

This topic has been closed for replies.
Correct answer lfcorullon13651490

If you want actual page (current page) don't use pages.items(0). Use,

instead, app.activeWindow.activePage

Em 8 de jan de 2018 15:13, "Awitmer" <forums_noreply@adobe.com> escreveu:

Adobe Community <https://forums.adobe.com/?et=watches.email.thread>

How do i specify which page to put the guides on?

criado por Awitmer

<https://forums.adobe.com/people/Awitmer?et=watches.email.thread> em *InDesign

Scripting* - Visualize a discussão completa

<https://forums.adobe.com/message/10088127?et=watches.email.thread#10088127>

1 reply

lfcorullon13651490
lfcorullon13651490Correct answer
Legend
January 8, 2018

If you want actual page (current page) don't use pages.items(0). Use,

instead, app.activeWindow.activePage

Em 8 de jan de 2018 15:13, "Awitmer" <forums_noreply@adobe.com> escreveu:

Adobe Community <https://forums.adobe.com/?et=watches.email.thread>

How do i specify which page to put the guides on?

criado por Awitmer

<https://forums.adobe.com/people/Awitmer?et=watches.email.thread> em *InDesign

Scripting* - Visualize a discussão completa

<https://forums.adobe.com/message/10088127?et=watches.email.thread#10088127>

AwitmerAuthor
Known Participant
January 8, 2018

Awesome! This is exactly the info I needed to know. I will mark this answer as correct.