TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: alanjt 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.
;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)
)
-
I don't know much about vlisp, but this line jumped out at me.
(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.
-
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.
-
This is what i use:
(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)
)
-
This is what i use:
(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.
-
Not a problem :)