ILoveMadoka Posted August 25, 2022 Posted August 25, 2022 I found this by Kent Cooper which works perfectly Original Here: (defun C:LAV (/ ss n vp); = Lock All Viewports (repeat (setq n (sslength (setq ss (ssget "_X" '((0 . "VIEWPORT")))))) (if (> (cdr (assoc 69 (entget (setq vp (ssname ss (setq n (1- n))))))) 1); not the Paper Space Viewport of its Layout (vla-put-DisplayLocked (vlax-ename->vla-object vp) -1); lock it ); if ); repeat ); defun My question using this same methodology, what is the UNLOCK process? I see code for other routines that do this and have 50 lines. I really like the brevity of his process... I looked for some information on vla-put-DisplayLocked but could find anything that helped me sort it out.. Quote
ILoveMadoka Posted August 25, 2022 Author Posted August 25, 2022 I found this by Lee-Mac as I was trying to figure out the process on my own but it's over my head.. LINK ;; Lock Selected Viewport (vl-load-com) (defun c:vpl nil ;;Locks Selected Viewports / Requires a pick (if (SSVPLock (ssget "_+.:E:S:L" '((0 . "VIEWPORT"))) :vlax-true) (princ "\n--> Viewport Locked.") ) (princ)) ;; Unlock Selected Viewport (defun c:vpu nil ;;Unlocks Selected Viewports / Requires a pick (if (SSVPLock (ssget "_+.:E:S:L" '((0 . "VIEWPORT"))) :vlax-false) (princ "\n--> Viewport Unlocked.") ) (princ)) ;; Lock All Viewports (defun c:vpla nil (SSVPLock (ssget "_X" '((0 . "VIEWPORT"))) :vlax-true) (princ "\n--> All Viewports Locked.") (princ)) ;; Unlock All Viewports (defun c:vpua nil (SSVPLock (ssget "_X" '((0 . "VIEWPORT"))) :vlax-false) (princ "\n--> All Viewports UnLocked.") (princ) ) (defun SSVPLock ( ss lock / i ) (if ss (repeat (setq i (sslength ss)) (vla-put-displaylocked (vlax-ename->vla-object (ssname ss (setq i (1- i)))) lock) t ) ) ) I have found 50 ways to Lock/Unlock VPorts. Not looking for a total different methodology... I was hoping to understand that (vla-put-DisplayLocked (vlax-ename->vla-object vp) -1) to see if it's merely a toggle.. Quote
mhupp Posted August 25, 2022 Posted August 25, 2022 (edited) To understand these lisps you need to look at the ssget in each. ;;Locks Selected Viewports / Requires a pick (if (SSVPLock (ssget "_+.:E:S:L" '((0 . "VIEWPORT"))) :vlax-true) ;;Unlocks Selected Viewports / Requires a pick (if (SSVPLock (ssget "_+.:E:S:L" '((0 . "VIEWPORT"))) :vlax-false) ;; Lock All Viewports (SSVPLock (ssget "_X" '((0 . "VIEWPORT"))) :vlax-true) ;; Unlock All Viewports (SSVPLock (ssget "_X" '((0 . "VIEWPORT"))) :vlax-false) These then feed into the SSVPLock Function. looking at both locks has :vlax-true and both unlocks have :vlax-false Using this to update your first code (defun C:LAV (/ ss n vp); = Lock All Viewports (if (setq ss (ssget "_X" '((0 . "VIEWPORT") (-4 . "!=") (69 . 1)))) ;just filter out the paper space viewports with ssget. ;this is saying select all viewports in drawing (! except) the ones that 69 = 1 aka paper space (foreach vp (mapcar 'cadr (ssnamex SS)) ;this list all the entity names in selection set with out haveing to use repeat and (1- i) ;(foreach vp (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) ;this is needed if you use ssget with out the "X" modifier (vla-put-DisplayLocked (vlax-ename->vla-object vp) :vlax-true) ;to unlock set to ":vlax-false" ) ); if ); defun Edited August 25, 2022 by mhupp 2 Quote
BIGAL Posted August 26, 2022 Posted August 26, 2022 As lock / unlock has 2 answers in some cases you can use different methods to achieve same result so (vla-put-DisplayLocked (vlax-ename->vla-object vp) -1); lock it the -1 and :Vlax-false are the same result. In vl intersectwith command you can use 0 1 2 3 as the intersection filter control as well as "acextendnone" plus others etc. Just use dumpit.lsp and pick a viewport DisplayLocked = 0 is unlocked. Quote
ILoveMadoka Posted August 31, 2022 Author Posted August 31, 2022 (ssget "_+.:E:S:L" '((0 . "VIEWPORT"))) Not even the slightest idea what this is doing... I've seen similar before but I figured it was something they found in Roswell... hence the "over my head" statement earlier.. Quote
ILoveMadoka Posted August 31, 2022 Author Posted August 31, 2022 should have started with the Google I suppose.. Quote
mhupp Posted August 31, 2022 Posted August 31, 2022 52 minutes ago, ILoveMadoka said: Not even the slightest idea what this is doing... Its acting like entsel for viewports only but also filtering out locked layers. http://www.lee-mac.com/ssget.html Quote
ILoveMadoka Posted September 1, 2022 Author Posted September 1, 2022 (edited) Thank you all so very much!! Edited September 1, 2022 by ILoveMadoka 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.