zoom extents in one cmd.

zoom extents in one cmd.

smallƑish
Advocate Advocate
1,759 Views
12 Replies
Message 1 of 13

zoom extents in one cmd.

smallƑish
Advocate
Advocate

Is that possible to make a shortcut?

A shortcut cmd "zz" that could do zoom extends as below;

Command: Z
ZOOM
Specify corner of window, enter a scale factor (nX or nXP), or
[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: e

 

 

0 Likes
Accepted solutions (2)
1,760 Views
12 Replies
Replies (12)
Message 2 of 13

ВeekeeCZ
Consultant
Consultant

That is what the mouse wheel double click does.

Message 3 of 13

smallƑish
Advocate
Advocate

omg !! lol

0 Likes
Message 4 of 13

ВeekeeCZ
Consultant
Consultant
Accepted solution

BTW it's fairly easy to write such a shortcut routine. Just follow the command line.

(defun c:zz () (command "zoom" "e") (princ))

Message 5 of 13

bigcarl5000kg
Advisor
Advisor
Accepted solution

Hi @smallƑish ,

 

here an LISP from @Kent1Cooper :

 

;;  ZoomAllLayouts.lsp
;;  Command names:
;;    ZLAL = Zoom Limits All Layouts
;;    ZEAL = Zoom Extents All Layouts
;;    ZAAL = Zoom All All Layouts
;;  Gets into all Layouts, goes to Paper Space and Zooms to the [Limits or
;;    Extents or All] in each; ends in Model Space and likewise Zooms there.
;;  Kent Cooper, last edited 2 April 2013

(defun ZAL (zopt / zd cmde exp)
  (defun zd (); = Zoom Determination
    (cond
      ((= zopt "L") (command (getvar 'limmin) (getvar 'limmax))); use Limits
      ((= zopt "E") (command "_extents"))
        ; Uses Extents option, not EXTMIN/EXTMAX System Variables,
        ; because those do not shrink on reduction of the actual extents
        ; until the next drawing regeneration or Zoom All-or-Extents, so
        ; using them could Zoom to a larger area than the current Extents.
      ((= zopt "A") (command "_all"))
    ); cond
  ); defun
  (setq
    cmde (getvar 'cmdecho)
    exp (= (getvar 'expert) 0)
  ); setq
  (if exp (setvar 'expert 1)); suppresses "About to regen -- proceed?"
  (setvar 'cmdecho 0)
  (foreach lay (layoutlist)
    (setvar 'ctab lay)
    (command "_.pspace" "_.zoom")
    (zd)
  ); foreach
  (setvar 'ctab "Model")
  (command "_.zoom")
  (zd)
  (if exp (setvar 'expert 0)); reset if changed
  (setvar 'cmdecho cmde)
  (princ)
); defun

(defun C:ZLAL (); = Zoom Limits All Layouts
  (ZAL "L")
); defun

(defun C:ZEAL (); = Zoom Extents All Layouts
  (ZAL "E")
); defun

(defun C:ZAAL (); = Zoom All All Layouts
  (ZAL "A")
); defun

 

 

 

 

+++ impossible immediately and miracles within 3 days +++
+++ the only constant is the change +++ stay tuned for more +++
+++ since 03/2023 is Advance Steel in maintenance mode, no further development +++
Message 6 of 13

fkellogg
Advocate
Advocate

I found the ZEAL command a while back, and love it.
The only thing I don't like is when there are elements outside the title block area, and it truly zooms to extents.
I wish there were a version that would zoom to the sheet area only.

0 Likes
Message 7 of 13

Kent1Cooper
Consultant
Consultant

@fkellogg wrote:

.... I wish there were a version that would zoom to the sheet area only.


Set your Limits to the sheet areas, and use the ZLAL command, which is for exactly that.

Kent Cooper, AIA
0 Likes
Message 8 of 13

fkellogg
Advocate
Advocate

I will have to look to see if I have the ZLAL version of that.

0 Likes
Message 9 of 13

Kent1Cooper
Consultant
Consultant

See lines 3 and 41-43 of the code at Message 5.

Kent Cooper, AIA
0 Likes
Message 10 of 13

fkellogg
Advocate
Advocate

I already had ZLAL in a separate file, just forgot it was there, in all my excitement of finding ZEAL.

 

0 Likes
Message 11 of 13

Sea-Haven
Mentor
Mentor

Two parts to the zoom to title block in layouts, I would find the title block in the layout and force a move of all objects so title block is at 0,0 for other programs like our "Autoplot". So using same code can use Zoom "W" window by getting the "Bounding Box' of the title block.

This is the move part have a go at adding the zoom window. In our case the title block is known and at 1:1 true size so can do a zoom window -20,-20 then 821,574

 

; moves all objects in pspace to 0,0 alignment based on selected title block.
; By AlanH updated Oct 2025

(defun movelayouts ( / oldsnap plottablist xy)
  (setq oldsnap (getvar "osmode")) 
  (setvar "osmode" 0)
  
  (setq plottablist (layoutlist))
  (setvar 'ctab (nth 0 plottablist ))
  
  (setq  ent (entget (car (entsel "Pick Title Block:"))))
    (setq bname (cdr (assoc 2 ent)))
	
  (foreach tname plottablist
    (setvar "ctab" tname)
    (setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 bname)(cons 410 tname))))
    (setq xy (cdr (assoc 10 (entget (ssname ss 0)))))
    (command "move" "w" (getvar "extmax") (getvar "extmin")  "" xy "0,0")
    (command "zoom" "E") ; replace here zoom window
  )
  
  (setvar "osmode" oldsnap)
  (princ)
)
(movelayouts)

 

0 Likes
Message 12 of 13

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

... use Zoom "W" window by getting the "Bounding Box' of the title block. ....


You could do it by just using the ZOOM command's Object option with the title block, without the need to get its bounding box, nor to Move anything, nor to involve Osnap settings.

Kent Cooper, AIA
0 Likes
Message 13 of 13

Kent1Cooper
Consultant
Consultant
....
(command "move" "w" (getvar "extmax") (getvar "extmin")  "" xy "0,0")
....

But if you do want to Move things:

(command "_.move" "_all" "" xy "0,0")

Kent Cooper, AIA
0 Likes