Tile and fit all open windows with javascript

Explorer ,
Jul 17, 2021 Jul 17, 2021

Copy link to clipboard

Copied

Hi, new to ai scripting.

Trying to tile a bunch of open ai documents and have all their view set to Tile and then  Fit all in Window or Fil Artboard in Window. 

The code below only works on 1 window, how do i looped the filall in all open docs?

for (var i = app.documents.length-1; i >= 0; i--) {  
var doc = app.documents[i];
{
app.documents.arrange(DocumentLayoutStyle.VERTICALTILE);
app.executeMenuCommand("fitall");
}
}
Thank you for your insights.
TOPICS
Scripting

Views

62

Likes

Translate

Translate

Report

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

correct answers 1 Correct Answer

Enthusiast , Jul 17, 2021 Jul 17, 2021
for (var i = 0; i < app.documents.length; i++) { app.documents[i].activate(); app.executeMenuCommand("fitall"); }

Likes

Translate

Translate
Explorer ,
Jul 17, 2021 Jul 17, 2021

Copy link to clipboard

Copied

The Tile command only need to run once, so that works
I think the problem is that you can't iterate 

app.executeMenuCommand("fitall");

I tried doc.executeMenuCommand('fitall"); it didn't work.


Apology for the typo in my first post, can't edit it. 

Likes

Translate

Translate

Report

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
Enthusiast ,
Jul 17, 2021 Jul 17, 2021

Copy link to clipboard

Copied

 

for (var i = 0; i < app.documents.length; i++) {  
    app.documents[i].activate();
    app.executeMenuCommand("fitall");
}

 

Likes

Translate

Translate

Report

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 17, 2021 Jul 17, 2021

Copy link to clipboard

Copied

LATEST

thank you, made my day!

Likes

Translate

Translate

Report

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