Author Topic: zoom extents in all layouts (help with routine)  (Read 2569 times)

0 Members and 1 Guest are viewing this topic.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
zoom extents in all layouts (help with routine)
« on: May 01, 2008, 03:45:16 PM »
i found this floating around here a while back. i use it regularly, but i was wondering if it is possible to change it so it will NOT zoom extents in modelspace in addition to zoom extents in all paperspace layouts?

if i remember correctly it was alan's code, but i'm not 100% on that, it was undocumented and i completely forgot to say who did it.

Code: [Select]
;zoom extents in all layouts
(defun c:zal (/ *acad* *doc* layouts ct lay)
  (vl-load-com)
  (setq   *acad*   (vlax-get-acad-object)
   *doc*   (vla-get-activedocument *acad*)
   layouts   (vla-get-layouts *doc*)
  )
  (setq ct (vla-get-activelayout *doc*))
  (vlax-for lay   layouts         ; step through layouts
    (vla-put-activelayout *doc* lay)   ; activate layout
    (if   (= (vla-get-activespace *doc*) 0) ; If in paperspace
      (if (= (vla-get-mspace *doc*) :vlax-true)
               ; in mspace viewport
   (vla-put-mspace *doc* :vlax-false) ; inactivate vp
      )               ; endif
    )               ;endif
    (vla-zoomextents *acad*)
  )
  (vla-put-activelayout *doc* ct)
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Guest

  • Guest
Re: zoom extents in all layouts (help with routine)
« Reply #1 on: May 01, 2008, 03:49:19 PM »
I don't know much about vlisp, but this line jumped out at me.

Code: [Select]
(vla-zoomextents *acad*)
I'd say comment it out and let 'er rip.
I'm sure someone with more experience with vlisp will chime in and correct me if I'm wrong.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: zoom extents in all layouts (help with routine)
« Reply #2 on: May 01, 2008, 03:52:54 PM »
Check the layouts name, and if it isn't equal to Model, then let it do it's thing, but if it is, then just go to the layout.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: zoom extents in all layouts (help with routine)
« Reply #3 on: May 01, 2008, 06:23:38 PM »
This is what i use:

Code: [Select]
(defun c:zal (/ doc ct)
  (setq doc (vla-get-activedocument
      (vlax-get-acad-object)
    )
ct  (vla-get-activelayout doc)
  )
  (vlax-map-collection
    (vla-get-layouts doc)
    '(lambda (x)
       (if (/= (vla-get-name x) "Model")
(progn
   (vla-put-activelayout doc x)
   (if (= (vla-get-mspace doc) :vlax-true)
     (vla-put-mspace doc :vlax-false)
   )
   (vla-zoomextents (vlax-get-acad-object))
)
       )
     )
  )
  (vla-put-activelayout doc ct)
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: zoom extents in all layouts (help with routine)
« Reply #4 on: May 01, 2008, 08:09:47 PM »
This is what i use:

Code: [Select]
(defun c:zal (/ doc ct)
  (setq doc (vla-get-activedocument
      (vlax-get-acad-object)
    )
ct  (vla-get-activelayout doc)
  )
  (vlax-map-collection
    (vla-get-layouts doc)
    '(lambda (x)
       (if (/= (vla-get-name x) "Model")
(progn
   (vla-put-activelayout doc x)
   (if (= (vla-get-mspace doc) :vlax-true)
     (vla-put-mspace doc :vlax-false)
   )
   (vla-zoomextents (vlax-get-acad-object))
)
       )
     )
  )
  (vla-put-activelayout doc ct)
  (princ)
)

ronjonp, that's perfect. thank you for sharing.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7529
Re: zoom extents in all layouts (help with routine)
« Reply #5 on: May 02, 2008, 09:53:25 AM »
Not a problem :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC