Copy link to clipboard
Copied
I would like to set different properties by script, like rulerOrigin, zoomPercentage and so on.
The properties I want to set are in different positions in the object model.
If I set them individually for each node in the object model (does this make sense?), it works as expected:
var doc = app.documents[0];
doc.viewPreferences.properties = {
rulerOrigin: RulerOrigin.PAGE_ORIGIN,
}
doc.layoutWindows[0].properties = {
zoomPercentage: 100,
}
However, it would be more elegant, do put everything in doc.properties like so:
doc.properties = {
viewPreferences: {
rulerOrigin: RulerOrigin.PAGE_ORIGIN,
}
}
Unfortunately, I can’t figure out, how to add doc.layoutWindows[0].
The following code doesn’t work:
doc.properties = {
viewPreferences: {
showFrameEdges: true,
},
layoutWindows.item(0): {
zoomPercentage: 100,
}
}
Any idea, how this is done?
---
By the way: I’m not sure what layoutWindows[0] actually refers to.
I guess it is meant to distinguish between multiple views of the same document. Am I right here?
Regards, Martin
The document has a windows property, but that’s a collection not a single object with its own properties like viewPreferences. Even though the length of the windows collection is probably only 1, you will need to set the properties of the window separately. Same would be true of any document property that is a collection, e.g. stories.
Copy link to clipboard
Copied
Hi Martin, Windows are a property of the application not the document, so to set the zoom percentage try:
app.activeWindow.zoomPercentage = 100;
Copy link to clipboard
Copied
Thank you @rob day!
This works, but it’s not what I was trying to archive for two reasons:
Copy link to clipboard
Copied
The document has a windows property, but that’s a collection not a single object with its own properties like viewPreferences. Even though the length of the windows collection is probably only 1, you will need to set the properties of the window separately. Same would be true of any document property that is a collection, e.g. stories.
Copy link to clipboard
Copied
Thank you, @rob day!
Just to be clear: So the structure I would prefer is simply not possible. Am I right?
Am I correct in assuming, that window[0] and window[1] are different views of the same document (as you would get via the Window → Arrange → New window for "filename.indd" menu)?
Copy link to clipboard
Copied
Right, I don’t think it would be possible with any property that is a collection. Here’s a list of document properties—Description will tell you if it is a collection:
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Document.html
Am I correct in assuming, that window[0] and window[1] are different views of the same document (as you would get via the Window → Arrange → New window for "filename.indd" menu)?
Yes. Create a new window for the active document and run this:
$.writeln(app.activeDocument.windows.length)
//returns 2
Find more inspiration, events, and resources on the new Adobe Community
Explore Now