Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Add 'Escape from Viewport' to lisp

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
325 Views, 2 Replies

Add 'Escape from Viewport' to lisp

I have found this lisp from BIGAL (http://www.cadtutor.net/forum/showthread.php?60319-Zoom-extents-all-layout-tabs) here.  I made a small change to it to give it a command name.  (Mainly this was guess and check based on structures from other lisps I have to get this to work)  I have one issue, that I can't seem to find a solution for and seems to be present on all the similar lisps I have found.

 

I would like to zoom extent all layout pages.  However if there is a viewport active it will zoom extents the viewport even if it is locked.  This is a problem because often me or someone else in the office will click the next layout tab without escaping the viewport.  Then if we run this command on save viewport scales will go out of wack.

 

Is it possible to add a line of code that says something like "if in model space go to paper space/escape viewport" and have this run on each layout before it is zoomed.  If not let me know so I'm not searching for hours but if it can be and you could tell me how to add it I'd greatly appreciate it.  Thank you!

; goes through all layout tabs and zooms all
; By Alan H june 2011

(vl-load-com)
(defun c:zea ()
 (command "_.pspace")
 (setq curtab (getvar "Ctab"))
 (setq this_dwg (vlax-get-acad-object))
 (foreach d (layoutlist)
      (setvar "CTAB" d)
      (vla-ZoomExtents this_dwg)
 )
 (setvar "ctab" curtab)
 (princ)
)

 

2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

It sounds like all you need to do is move your 'pspace' line into the foreach statement.

 

(vl-load-com)
(defun c:zea ()
 (setq curtab (getvar "Ctab"))
 (setq this_dwg (vlax-get-acad-object))
 (foreach d (layoutlist)
      (setvar "CTAB" d)
      (command "_.pspace")
      (vla-ZoomExtents this_dwg)
 )
 (setvar "ctab" curtab)
 (princ)
)

 

Message 3 of 3
Anonymous
in reply to: Anonymous

That was exactly what I was looking to do.  Eventually I will learn how to create and alter lisps!  Thank you!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost