Jump to content

Unlocking All Viewports (Kent Cooper?) (Kent1Cooper)


Recommended Posts

Posted

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..

 

Posted

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..

Posted (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 by mhupp
  • Like 2
Posted

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.

Posted

 

(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.. 😉

Posted

should have started with the Google I suppose..

Posted (edited)

Thank you all so very much!!

Edited by ILoveMadoka

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...