PDA

View Full Version : Locking Viewports


Cad4men
2004-07-28, 05:03 AM
Does anyone have available a routine that will automatically lock all paperspace viewports upon opening a drawing file, regardless of the quantity or whether the drawing was previously saved in model space.
I would like to load it in acad2004doc.lsp, as this file loads from our server, across all cad stations.

Thanks,

Jerry

miff
2004-07-28, 07:04 AM
Add this to the end of your lisp file....

(defun vplock (yesno / ss lock x obj)
(vl-load-com)
(if (setq ss (ssget "X" '((0 . "VIEWPORT")(-4 . "/=")(69 . 1))))
(progn
(if (= "y" yesno) (setq lock :vlax-true)(setq lock :vlax-false))
(setq x 0)
(while (< x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss x)))
(vla-put-displaylocked obj lock)
(setq x (1+ x))
)
)
)
(princ)
)
(vplock "y")


HTH

peter
2004-07-28, 01:21 PM
Here are my versions

You may have to change the method of selecting the objects with the acaddoc.lsp. If you get errors from these let me know.

Peter Jamtgaard

(defun C:LockVP (/ intCount ssSelections)
(setq ssSelections (ssget "x" (list (cons 0 "VIEWPORT"))))
(repeat (setq intCount (sslength SSET))
(vla-put-DisplayLocked (vlax-ename->vla-object
(ssname ssSelections
(setq intCount (1- intCOunt))))
:vlax-true
)
)
(prin1)
)

(defun C:UnlockVP (/ intCount ssSelections)
(setq ssSelections (ssget "x" (list (cons 0 "VIEWPORT"))))
(repeat (setq intCount (sslength SSET))
(vla-put-DisplayLocked (vlax-ename->vla-object
(ssname ssSelections
(setq intCount (1- intCOunt))))
:vlax-false
)
)
(prin1)
)

CAB2k
2004-07-28, 02:30 PM
Here is one that setsthe vp to red when locked & green when unlocked.


(defun c:vpunlockall () ; 06/07/04
(vl-load-com)
(vlax-for lay
(vla-get-layouts
(vla-get-activedocument
(vlax-get-acad-object)
)
)
(if (eq :vlax-false (vla-get-modeltype lay))
(vlax-for ent (vla-get-block lay) ; for each ent in layout
(if (= (vla-get-objectname ent) "AcDbViewport")
(progn
(vla-put-displaylocked ent :vlax-false)
(vla-put-color ent 3); 3 green
)
)
)
)
)
)


(defun c:vplockall () ; 06/07/04
(vl-load-com)
(vlax-for lay
(vla-get-layouts
(vla-get-activedocument
(vlax-get-acad-object)
)
)
(if (eq :vlax-false (vla-get-modeltype lay))
(vlax-for ent (vla-get-block lay) ; for each ent in layout
(if (= (vla-get-objectname ent) "AcDbViewport")
(progn
(vla-put-displaylocked ent :vlax-true)
(vla-put-color ent 1);1 red
)
)
)
)
)
)