Copy link to clipboard
Copied
Frequently I use nice neat guides for laying out objects and text in my InDesign document.
So, I thought I might create a simple script that would draw guides on my actively selected page of my InDesign file in certain proportions.
But it's not working! I don't know exactly why other than that I'm pretty sure I didn't call the active page width and height correctly. It's important that this script is generated on whatever the "active" page is, because it could be any page of a document, and different pages might use different proportions for laying things out, like 20% of the document's height at a time.
Here's part of a script for attempting to draw those guides
This is the only component of my script that doesn't work. And it probably doesn't work because I didn't correctly call the actively selected page width and height, so how do I do that?
Copy link to clipboard
Copied
Hi @dane13860245 , A page doesn’t have a pageWidth property. You can get the document’s default pagewidth with this:
doc.documentPreferences.pageWidth
But the activePage could have a custom size so get the width from the page.bounds property:
var doc = app.activeDocument;
//var pw = doc.documentPreferences.pageWidth
var ap = app.activeWindow.activePage;
var b = ap.bounds;
var pw = b[3]-b[1]
for (var i = 0; i<6;++i){
ap.guides.add({location: pw*i*0.2, orientation: HorizontalOrVertical.VERTICAL});
}
probably better
Copy link to clipboard
Copied
Thank you for the reply!
What is the b[3] - b[1]? The brackets indicate an array of some sort, but I'm just looking to be able to select any page at any time and apply the script.
Copy link to clipboard
Copied
Bounds - same as GeometricBounds for objects.
[top, left, bottom, right]
[0,1,2,3]
Copy link to clipboard
Copied
If you know none of the pages have been resized, you could set the pw variable to the document’s documentPreferences pageWidth property, but the page itself doesn’t have a pageWidth property which is why your script throws an error. Getting the width from the .bounds property is just safer.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now