I tried this routine and the same thing happened to me. I realized that whatever viewport is active (meaning your cross-hairs are in model space of that viewport) zooms extents. I think that is why certain viewports inside the layout are zooming out as you say. I hope this helps in "solving" this lisp routine issue. I need it for my DWF creation since whenever I create a DWF and view it, the sheets 'save' whatever zoom factor I was at in the drawing, rather than showing the entire sheet (like a PDF does).
John
@Johnw wrote:I tried this routine and the same thing happened to me. I realized that whatever viewport is active (meaning your cross-hairs are in model space of that viewport) zooms extents. I think that is why certain viewports inside the layout are zooming out as you say. I hope this helps in "solving" this lisp routine issue. I need it for my DWF creation since whenever I create a DWF and view it, the sheets 'save' whatever zoom factor I was at in the drawing, rather than showing the entire sheet (like a PDF does).
John
Here's what I use, which does the Limits rather than the Extents. The Pspace command in it forces it out of any viewport you may be in, in a given layout.
;; ZoomLimitsAllLayouts.lsp [command name: ZLAL]
;; To get into all Layouts, go to Paper Space in and Zoom to the Limits for each,
;; ending in Model Space and Zooming to the Limits there also.
;; Kent Cooper, February 2011
(defun C:ZLAL ()
(foreach lay (layoutlist)
(setvar 'ctab lay)
(command "_.pspace" "_.zoom" (getvar 'limmin) (getvar 'limmax))
); end foreach
(setvar 'ctab "Model")
(command "_.zoom" (getvar 'limmin) (getvar 'limmax))
); end defun
This should do the same for the Extents [untested]:
;; ZoomExtentsAllLayouts.lsp [command name: ZEAL]
;; To get into all Layouts, go to Paper Space in and Zoom to the Extents for each,
;; ending in Model Space and Zooming to the Extents there also.
;; Kent Cooper, November 2011
(defun C:ZEAL ()
(foreach lay (layoutlist)
(setvar 'ctab lay)
(command "_.pspace" "_.zoom" "_extents")
); end foreach
(setvar 'ctab "Model")
(command "_.zoom" "_extents")
); end defun
@Kent1Cooper wrote:....Here's what I use, which does the Limits ....
This should do the same for the Extents ....
I worked up more sophisticated versions of those ZLAL [Zoom-Limits-All-Layouts] and ZEAL [Zoom-Extents-All-Layouts] commands [two commands in one ZoomAllLayouts.lsp file]. They turn off command echoing, and suppress the "About to regenerate -- proceed?" message if needed.
I found out through a collegue of mine that if you add the following line to the original routine, ZEA, it will put you in paperspace at each tab before zooming extents that way it won't effect the viewport zooming that was a problem in the original code.
(defun C:ZEA (/ acad acdoc aclay)
(setq acad (vlax-get-acad-object)
acdoc (vla-get-ActiveDocument acad)
aclay (vla-get-ActiveLayout acdoc)
); setq
;; Modified by Bob Shaw 10-Nov-2011 for John Wagner at Davis Bews Design Group
(vlax-for layout (vla-get-Layouts acdoc)
(vla-put-ActiveLayout acdoc layout)
(if (/= "Model" (getvar "ctab"))
(progn
(command "_pspace")
(princ)
(vla-ZoomExtents acad)
); progn
); if
); vlax-for
(vla-put-ActiveLayout acdoc aclay)
(princ)
); function
Here's another way:
(defun c:zea ( / acapp acdoc aclay ) (setq acapp (vlax-get-acad-object) acdoc (vla-get-activedocument acapp) aclay (vla-get-activelayout acdoc) ) (vlax-for layout (vla-get-layouts acdoc) (vla-put-activelayout acdoc layout) (if (eq acpaperspace (vla-get-activespace acdoc)) (vla-put-mspace acdoc :vlax-false) ) (vla-zoomextents acapp) ) (vla-put-activelayout acdoc aclay) (princ) ) (vl-load-com) (princ)
@Johnw wrote:.... if you add the following line to the original routine, ZEA, it will put you in paperspace at each tab before zooming extents that way it won't effect the viewport zooming that was a problem in the original code.
....
Yes, that's what was different about my earlier post from the original: the inclusion of the Pspace command.
Since it appears you're not including Model Space, you can accomplish it with as little as this:
(defun C:ZEAL ()
(foreach lay (layoutlist)
(setvar 'ctab lay)
(command "_.pspace" "_.zoom" "_extents")
); foreach
); defun
Or if you want to return to the initial Layout:
(defun C:ZEAL (/ lyt)
(setq lyt (getvar 'ctab))
(foreach lay (layoutlist)
(setvar 'ctab lay)
(command "_.pspace" "_.zoom" "_extents")
); foreach
(setvar 'ctab lyt)
); defun
Hi,
I tested all of these routines and they worked very well. The problem is that my computer took 5 or 6 minutes to complete each one in a drawing with 53 layout tabs.
I wonder if there is a way to turn off REGENAUTO for the tabs, during the execution of the routine so that the execution could be faster? At the end we would need only to do REGENALL.
Thanks!
@msarqui wrote:....
I tested all of these routines and they worked very well. The problem is that my computer took 5 or 6 minutes to complete each one in a drawing with 53 layout tabs.
I wonder if there is a way to turn off REGENAUTO for the tabs, during the execution of the routine so that the execution could be faster? At the end we would need only to do REGENALL.
....
I can't find anything in Help to confirm it directly, but I believe that Zooming to the Extents always forces a regeneration, anyway. [It does say that for Zoom All, and it lists both Zoom All and Zoom Extents as updating the EXTMIN & EXTMAX System Variables, which I believe REGEN also does.] If that's correct, I don't think the REGENAUTO command or REGENMODE System Variable would help. And it would argue for using the Zoom Limits version instead of the Zoom Extents version, if you can, because that won't cause a regeneration unless you're starting zoomed in very close.
hi i Run the LISP and is working fine to do ZoomExtends. But How do i make the lisp run evry time i open a document.? Is there a way?
I've been using this lisp for several years
(defun c:zea ( / acapp acdoc aclay ) (setq acapp (vlax-get-acad-object) acdoc (vla-get-activedocument acapp) aclay (vla-get-activelayout acdoc) ) (vlax-for layout (vla-get-layouts acdoc) (vla-put-activelayout acdoc layout) (if (eq acpaperspace (vla-get-activespace acdoc)) (vla-put-mspace acdoc :vlax-false) ) (vla-zoomextents acapp) ) (vla-put-activelayout acdoc aclay) (princ) ) (vl-load-com) (princ)
Is there a way to suppress the "Restoring cached viewports - Regenerating layout." from displaying in the command line?
I like to see my recent cmd line history. Even in a smaller drawing files, this routine spams the cmd line.
EDIT: I tried this, but was unsuccessful...
(defun *error* (msg)
(if (member msg '("Restoring cached viewports - Regenerating layout." ))
(princ)
) ;if
) ;*error*
probably if we set the variable maxactvp to 2 during execution of these routines we can avoid force regeneration in zoom extens procedure?