Hi there, first post for me. I am fairly green when it comes to lisp routines. I mean, I know what they do, and how to execute them, but beyond that I am grasping.
My question, I have two routines that I like to execute before I close a drawing; one is to lock all vports, and the other zoom extents all viewports. I have been trying to combine the two into one routine but it is giving me much grief. Any help would be appreciated.
Also, to take that one step further, it would be great if these routines could both simply be executed upon closing of the drawing. It would seem that this must be possible...I just haven't the knowledge.
Lisp to lock vports:
Code:
;;Program by Dann Brower 2006
(defun C:vpl (/ kw)
(setq kw "LOCK")
(vplocks kw)
(princ)
)
(defun C:vpu (/ kw)
(setq kw "UNLOCK")
(vplocks kw)
(princ)
)
(defun vpLocks (kw / kval doc adoc lao cnt inc cvprt blk pw)
(vl-load-com)
(if (= kw "LOCK")
(setq kval :vlax-true)
(if (= kw "UNLOCK")
(setq kval :vlax-false)
)
)
(setq doc (vlax-get-object "AutoCad.Application")
adoc (vla-get-ActiveDocument doc)
lao (vla-get-Layouts adoc)
cnt (vla-get-Count lao)
inc 0
)
(repeat cnt
(setq cvprt (vla-Item lao inc)
inc (+ inc 1)
blk (vla-get-Block cvprt)
)
(vlax-for itm blk
(if
(vlax-property-available-p itm 'DisplayLocked)
(progn
(vla-put-DisplayLocked itm kval)
(vla-update itm)
)
)
)
)
(princ)
)
Lisp to zoom all vports:
Code:
(defun zoom_all_layouts (/ lay layouts *acad* *doc*)
(vl-load-com)
(setq *acad* (vlax-get-acad-object)
*doc* (vla-get-activedocument *acad*)
layouts (vla-get-layouts *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*)
)
)
(defun c:zal ()
(zoom_all_layouts)
)
Cheers,
Billy
[ Moderator Action = ON ] What are [ CODE ] tags... [ Moderator Action = OFF ]