;;;------------VPLock.lsp---------------------- ;;; Purpose: Lock/Unlock Viewports by Selection ;;; Author : Herman Mayfarth ;;; Date : 1 July 2004 ;;; Version: 1.0 ;;; Copyright © 2004 Herman Mayfarth ;;; All rights reserved. ;;; Supplied "as is," and without warranty, express or implied. ;;; Permission granted to use & redistribute without fee, ;;; Provided file header including copyright notice remains intact. ;;;--------------------------------------------------------------- ;;locks viewports (defun C:VPLock ( / lst ss thisdwg) (vl-load-com) (setq thisdwg (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark thisdwg) (princ "\nSelect Viewports to Lock: ") (and ;in lieu of (if ss ..) following sget (setq ss (ssget '((0 . "VIEWPORT")))) ;;build a list of enames from the ss (setq i 0) (repeat (sslength ss) (setq lst (cons (ssname ss i) lst)) (setq i (1+ i)) );repeat ;;convert the enames to vla-objects ;;and lock the viewports (mapcar '(lambda (x) (vla-put-displaylocked (vlax-ename->vla-object x) :vlax-true) );lambda lst );mapcar );and (vla-endundomark thisdwg) (princ) );C:VPLock ;;unlocks viewports (defun C:VPUnlock ( / lst ss thisdwg) (vl-load-com) (setq thisdwg (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark thisdwg) (princ "\nSelect Viewports to Unlock: ") (and (setq ss (ssget '((0 . "VIEWPORT")))) ;;build a list of enames from the ss (setq i 0) (repeat (sslength ss) (setq lst (cons (ssname ss i) lst)) (setq i (1+ i)) );repeat ;;convert the enames to vla-objects ;;and unlock the viewports (mapcar '(lambda (x) (vla-put-displaylocked (vlax-ename->vla-object x) :vlax-false) );lambda lst );mapcar );and (vla-endundomark thisdwg) (princ) );C:VPUnlock ;;load prompts (princ "\n VPLock 1.0 © 2004 Herman Mayfarth") (princ "\n VPLock to Lock Viewports, VPUnlock to Unlock") (princ)