thalon
Mechanical
- Sep 24, 2003
- 68
I've got a LISP routine that will toggle a selected viewports "Display Locked" switch.
Please feel free use use/modify to suit your needs.
Please feel free use use/modify to suit your needs.
Code:
; Viewport Display Lock Toggle
; Written by: Kevin petursson
; Aid From: Autodesk Discussion groups
; December 15, 2005
;
; Toggle the "Display Locked" Variable of selected viewports based on the first view port selected
(defun c:vplocktoggle (/ Ename ss )
(princ "\nSelect Viewport...")
;Get selection set, allow only viewports
(setq ss (ssget '((0 . "viewport"))))
(if (IsVpLocked (setq Ename (ssname ss 0)))
;Viewport is locked. Run Unlock commands
(progn
(princ "\nViewport selected is Locked")
;Unlock viewport
(command "mview" "Lock" "OFF" ss "")
;Change viewport color to red to indicate it is Unlocked
(command ".change" ss "" "p" "c" "1" "")
(princ "\nViewport is now Unlocked")
)
;Viewport is unlocked. Run Lock commands
(progn
(princ "\nViewport selected is Unlocked")
;Lock viewport
(command "mview" "Lock" "ON" ss "")
;Change viewport color to ByLayer to indicate it is Locked
(command ".change" ss "" "p" "c" "bylayer" "")
(princ "\nViewport is now Locked")
)
)
(princ)
)
; This function was downloaded from the autodesk discussion groups
; Return: T if locked, Nil otherwise
(defun IsVpLocked (Ename)
(eq 16384 (logand 16384 (cdr (assoc 90 (entget Ename)))))
)
[\code]