Copy link to clipboard
Copied
Hi,
Document.activeView is read-only.
Document.views is read-only.
How to use views in JS?
or
How to change view to "Fit in Window [apple] + [0]" (JS)?
BR
-a-
Copy link to clipboard
Copied
Hi,
1)use screenMode to change views
#target illustrator
if ( app.documents.length > 0 ) {
app.documents[0].views[0].screenMode = ScreenMode.DESKTOP; // different mode are DESKTOP, MULTIWINDOW or FULLSCREEN.
}
2) If you know your purcent which you need you can try this:
if ( app.documents.length > 0 ) {
app.documents[0].views[0].zoom = 1; // 1 is 100%
}
unfortunately, i don't know how to catch the size of window screen ![]()
Cya, art.chrome
Copy link to clipboard
Copied
Hi,
1) ScreenMode
DocumentWindowSize = DESKTOPSize / original MULTIWINDOWSize / FULLSCREENSize
it's "only window layout". do not modify document.view property.
2) Zoom
It is a good solution, but how to calculate and setup: center of view and number of zoom for fit?
- - -
Illustrator Menu -> View -> New view -> add name for actual view. (eg. "myView")
zoom +/- and/or move page in window
Save mydoc
Close mydoc
Open mydoc
Illustrator Menu -> View -> myView
It is working. How to use it in JS?
Copy link to clipboard
Copied
Hi,
I think that you can use muppet mark's script after that you have updated myZoom to the right zoom you want and save your doc with "docRef.save()", it should better if you use MULTIWINDOWS mode to calculate zoom
- when i open a doc , and push [mac]+[0] and save,it seems that this doc is saved with window coordinates and zoom.
indeed i'm not sure to understand want you need exactly, and if you need really a script.
Cya, art.chrome
Copy link to clipboard
Copied
This snippet should give you the basic idea. You can read & write to a view. Here I have used fill screen and calculated a zoom which represents 100% on my monitor (well as close as I need it) it should then center based on the artboard bounds. (this was done in CS2 only 1 artboard).
#target illustrator
var myMonitor = $.screens;
$.writeln(myMonitor);
docRef = app.activeDocument;
with (docRef) {
// Calculate my 100% veiw based on 1152x870!!!
var myZoom = 1600/1152
views[0].screenMode = ScreenMode.FULLSCREEN;
views[0].zoom = myZoom;
views[0].centerPoint = [width/2,height/2];
}
I also included where to get the montior size/res using script just in case you want to use this too.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more