wimal Posted September 29, 2013 Posted September 29, 2013 Is there a command to lock and unlock all view ports at once. If not can somebody develop a LISP code.Please. Quote
steven-g Posted September 29, 2013 Posted September 29, 2013 (edited) Macro Lock all _LA;LO;*;; & Unlock all _LA;U;*;; OOPS why did I read that as layers Edited September 29, 2013 by steven-g Quote
pBe Posted September 29, 2013 Posted September 29, 2013 A quickly written code (Defun c:vplk () (setq d (ssget "_x" '((0 . "VIEWPORT")))) (vplock d T)(princ)) (Defun c:vpun () (setq d (ssget "_x" '((0 . "VIEWPORT")))) (vplock d nil) (princ) ) (Defun vplock (sel flg) (setq mode (if flg :vlax-true :vlax-false)) (repeat (setq i (sslength sel)) (vlax-put-property (vlax-ename->vla-object (ssname sel (Setq i (1- i)))) 'DisplayLocked mode) ) (princ (strcat "\nViewports " (if flg "" "Un" ) "locked"))(princ) ) (vl-load-com) Quote
gS7 Posted September 29, 2013 Posted September 29, 2013 (edited) Another ... (defun c:Test(/ User_request ss adoc layers lay ) ;;ViewPorts Lock and Unlock ::Ganesh Shetty ;;2013 (vl-load-com) (initget "Lock Unlock") (if (and (setq User_request (getkword "\nViewports want to [Lock / Unlock]:")) (setq ss (ssget "X" '((0 . "VIEWPORT")))) ) (progn (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (setq layers (vla-get-layers adoc)) (vlax-for vp (setq ss (vla-get-activeselectionset adoc)) (setq lay (vla-Item layers (vla-get-layer vp))) (if (= (vlax-get-property lay "lock") :vlax-True) (vlax-Put-Property lay "lock" :Vlax-false) ) (if (= user_request "Lock") (progn (if (= (vlax-get-property vp 'Displaylocked) :vlax-false) (vlax-put-Property vp 'DisplayLocked :vlax-True) ) ) (progn (if (= (vlax-get-property vp 'Displaylocked) :vlax-true) (vlax-put-property vp 'Displaylocked :vlax-false) ) ) ) ) (vla-delete ss) ) ) (princ) ) Edited September 29, 2013 by gS7 Code revised Quote
Pablo Ferral Posted September 29, 2013 Posted September 29, 2013 There are some examples of how to do it with a macro on a tool palette here:http://www.cad-notes.com/2011/12/eleven-killer-tool-palette-macros-for-working-with-autocad-viewports/ Quote
Tharwat Posted September 29, 2013 Posted September 29, 2013 I hope that the OP has the viewports on Unlocked layers Someone needs to localize his variables as well . Quote
wimal Posted September 29, 2013 Author Posted September 29, 2013 Thanks gentlemen, both codes are working nicely. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.