Jump to content

Recommended Posts

Posted

Is there a command to lock and unlock all view ports at once.

If not can somebody develop a LISP code.Please.

Posted (edited)

Macro Lock all

_LA;LO;*;;

& Unlock all

_LA;U;*;;

 

OOPS why did I read that as layers

Edited by steven-g
Posted

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)

Posted (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 by gS7
Code revised
Posted

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/

Posted

I hope that the OP has the viewports on Unlocked layers :D

Someone needs to localize his variables as well . ;)

Posted

Thanks gentlemen, both codes are working nicely.

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