Michael Schroeder Posted January 24 Share Posted January 24 (edited) Looking to get my feet wet and write a small menu command script for have all sheet layers zoom be set to fit to page/window. Edited January 24 by Michael Schroeder sp, and clarification 1 Quote Link to comment
Pat Stanford Posted January 24 Share Posted January 24 Try the following script and see if it meets your needs. 1. This changes the selection state of objects by deselecting everything as I had to draw a new object to fit to. 2. This can be run with any layer active and that layer will still be active after the script it run. 3. There is only one Zoom and View setting in the file, so if you have layers with different page sizes, the zoom will be set to whatever the last SL in the stacking order is. As long as your Sheets are all centered around the same origin and you have not moved the Page Area on any sheets, it should only be an issue of zooming in/out. 4. This command is based on the Page Area, so if you have objects outside of the page area, they might be outside the viewable area. Procedure FitSLs; {©2025 Pat Stanford - pat@coviana.com} {licensed under the Boost Software License 1.0} {https://github.com/boostorg/boost/blob/master/LICENSE_1_0.txt} {TL/DR Use as you want, attribution for source, No warranty} VAR H1, H2, OriginalL :Handle; X1,Y1,X2,Y2 :Real; BEGIN OriginalL:=ActLayer; H1:=FLayer; While H1 <> Nil DO BEGIN If GetObjectVariableInt(H1, 154) = 2 then BEGIN Layer(GetLName(H1)); GetDrawingSizeRectN(H1, X1,Y1,X2,Y2); Rect(X1,Y1,X2,Y2); H2:=LNewObj; DSelectAll; SetSelect(H2); DoMenuTextByName('Fit To Objects',0); Delobject(H2); End; H1:=NextLayer(H1); End; Layer(GetLName(OriginalL)); End; Run(FitSLs); Quote Link to comment
JBenghiat Posted January 24 Share Posted January 24 @Michael Schroeder, do you have Separate Sheet Views turned on in Preferences | Edit? If so, you can always turn this option off if all your pages are the same size. @Pat Stanford I believe what Michael is requesting is: Iterate over each Sheet Layer: - Make active - DoMenuTextByName('Fit to Window'); Quote Link to comment
Pat Stanford Posted January 24 Share Posted January 24 Thank you Joshua. I was looking for that and could not find 'Fit to Window', so I used the work around using the 'Fit to Objects' after creating a rectangle matching the page area. So the script simplifies to: Procedure FitSLs; {©2025 Pat Stanford - pat@coviana.com} {licensed under the Boost Software License 1.0} {https://github.com/boostorg/boost/blob/master/LICENSE_1_0.txt} {TL/DR Use as you want, attribution for source, No warranty} VAR H1, H2, OriginalL :Handle; X1,Y1,X2,Y2 :Real; BEGIN OriginalL:=ActLayer; H1:=FLayer; While H1 <> Nil DO BEGIN If GetObjectVariableInt(H1, 154) = 2 then BEGIN Layer(GetLName(H1)); DoMenuTextByName('Fit To Window',0); End; H1:=NextLayer(H1); End; Layer(GetLName(OriginalL)); End; Run(FitSLs); And if you do have Separate Sheet Views turned on in Options, then you can ignore my comment #3 in the first post as it will zoom every sheet layer to the correct drawing area. Quote Link to comment
Jonathan Pickup Posted January 24 Share Posted January 24 Hi Pat, in the past we used to have a script like that and we would add it to the saved view, then use the saved view to call the sheet layer. Not as elegant as yours, but for simple people like me used to work. I recently set up a project to use same views for each drawing so that we could ensure that the guides class was turned off on our sheet layers. The architect wanted to use guides on the sheet layers for the placement of the details. 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.