Jump to content

Auto Zoom Extent all layouts


apsonwane

Recommended Posts

Hi,

 

Is it possible to auto zoom extent all layouts in current drawing with single command using auto list routine?

I am using autocad 2011.

 

FYI, I found routine on this site (see below link), but this routine extents all vieports in active layout.

http://www.cadtutor.net/forum/showthread.php?36349-Zoom-Extents-All

 

Thanks in advance for your help.

 

Regards,

Ashish

Link to comment
Share on other sites

Zoom extends

;zOOM EXTENDS ALL LAYOUTS
(defun c:LZE (/ Ctab Layout)
 (princ "\nLayouts Zoom Extents")
 (setq Ctab (getvar "CTAB"))
 (foreach Layout (layoutlist)
   (command "LAYOUT" "S" Layout)
   (command "PSPACE")
   (command "ZOOM" "E")
 )
 (setvar "CTAB" Ctab)
 (princ)
)

 

 

Zoom window

(defun c:LZW (/ Ctab Layout P1 P2)
 (princ "\nLayouts Zoom Window")
 (if (/= (setq Ctab (getvar "CTAB")) "Model")
   (progn
     (command "PSPACE")

     (if (and
    (setq P1 (getpoint "\nSpecify first corner: "))
    (setq P2 (getcorner P1 "Specify opposite corner: "))
    )
       (foreach Layout (layoutlist)
         (command "LAYOUT" "S" Layout)
         (command "PSPACE")
         (command "ZOOM" "W" P1 P2)
       )
     )
   )
   (command "ZOOM" "W")
 )
 (setvar "CTAB" Ctab)
 (princ)
)

 

Both lisps NOT mine

Link to comment
Share on other sites

 

Both lisps NOT mine

 

Great routines sir.

 

But since they don't belong to you. Why did you remove the name of the Author ?

 

A very big question .

Link to comment
Share on other sites

(defun c:lze (/ This_Drawing lyouts)
(setq This_Drawing (vla-get-activedocument (vlax-get-acad-object))
    lyouts (vla-get-layouts  This_Drawing))
      (vlax-for ly lyouts
  (if (eq (vla-get-modeltype ly) :vlax-false)
     (progn
    (vl-cmdf "_.layout" "S" (vla-get-name ly))
    (vl-cmdf "_.Zoom" "E")
   )
 )
)
 )

 

 

oops :ouch: too late :)

Link to comment
Share on other sites

(defun c:lze (/ This_Drawing lyouts)
(setq This_Drawing (vla-get-activedocument (vlax-get-acad-object))
    lyouts (vla-get-layouts  This_Drawing))
      (vlax-for ly lyouts
  (if (eq (vla-get-modeltype ly) :vlax-false)
     (progn
    (vl-cmdf "_.layout" "S" (vla-get-name ly))
    (vl-cmdf "_.Zoom" "E")
   )
 )
)
 )

 

oops :ouch: too late :)

 

Nice one buddy, but it does not go back to the Model Space as it was before.

 

Thank you

Link to comment
Share on other sites

Hi,

 

Can we stop the screen fluctuations & scrooling of text over command line during execution of this LZE command??

This irritates eyes, specially when you have several layouts.

 

- Ashish

Link to comment
Share on other sites

(defun c:lze ( / ot ac )
 (vl-load-com)
 (setq ot (getvar 'CTAB) ac (vlax-get-acad-object))

 (foreach l (layoutlist) (setvar 'CTAB l) (vla-ZoomExtents ac))
 (setvar 'CTAB ot)
 (princ)
)

Or to avoid Zooming in Viewports:

 

(defun c:lze ( / ot ac doc )
 (vl-load-com)
 (setq ot (getvar 'CTAB) ac (vlax-get-acad-object) doc (vla-get-ActiveDocument ac))

 (foreach l (layoutlist)
   (setvar 'CTAB l) (vla-put-MSpace doc :vlax-false) (vla-ZoomExtents ac)
 )
 (setvar 'CTAB ot)
 (princ)
)

  • Thanks 1
Link to comment
Share on other sites

(vla-ZoomExtents ac)) !!!!

 

 

thats what i'm lookig for (slap forehead) ... cool Lee MAc you never cease to amazed us :)

 

(defun c:PE:LZE ()
  (vl-load-com)(setq prv (getvar 'CTAB) dwg (vlax-get-acad-object))
(mapcar '(lambda (x)
    (setvar 'CTAB x)
    (vla-ZoomExtents dwg))
    (layoutlist))
(setvar 'CTAB prv)
 )

 

To be honest, i never knew about (layoutlist) until today... learning new stuff everyday

:)

Edited by pBe
add code
Link to comment
Share on other sites

Zoom window one I sometimes use...

 

(defun c:LZW (/ ctab pt cor)
 ;; Layout Zoom Window (zoom to same window in all layouts)
 ;; Alan J. Thompson, 11.10.09
 (if (zerop (getvar 'tilemode))
   (progn (setq ctab (getvar 'ctab))
          (vla-put-MSpace
            (cond (*AcadDoc*)
                  ((setq *AcadDoc* (vla-get-activedocument
                                     (cond (*Acad*)
                                           ((setq *Acad* (vlax-get-acad-object)))
                                     )
                                   )
                   )
                  )
            )
            :vlax-false
          )
          (if (and (setq pt (getpoint "\nSpecify first corner:  "))
                   (setq cor (getcorner pt "\nSpecify opposite corner: "))
              )
            ((lambda (zoom)
               (foreach x (layoutlist)
                 (setvar 'ctab x)
                 (vla-put-MSpace *AcadDoc* :vlax-false)
                 (apply (function vla-ZoomWindow) zoom)
               )
               (setvar 'ctab ctab)
             )
              (cons *Acad* (mapcar (function vlax-3d-point) (list pt cor)))
            )
          )
   )
   (alert "Sorry, command not allowed in Model Tab.")
 )
 (princ)
)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...