;;---------------------=={ Object Lock }==--------------------;;
;; ;;
;; Purely academic code demonstrating the ability to use ;;
;; reactors to prevent modification of a selection of ;;
;; objects, and furthermore retain such security between ;;
;; drawing sessions. ;;
;; ;;
;; The code is written for demonstration only since it quite ;;
;; clearly isn't practical. The functionality can be ;;
;; matched by simply using a Locked Layer; and moreover ;;
;; don't get your hopes up in thinking that you can use this ;;
;; code to prevent third party modification of your drawings ;;
;; since the reactors need to be loaded before the lock is ;;
;; effective. And who's going to fall for that one... ;) ;;
;; ;;
;; The program uses two reactors: an Editor Reactor - to ;;
;; undo any modification of a selection of objects following ;;
;; the completion of a command or LISP program; and a ;;
;; Drawing Reactor - to save the handles of the locked ;;
;; Objects in a dictionary so that the reactors may be ;;
;; rebuilt when the drawing is next opened. ;;
;; ;;
;; The concept of 'undeleting' entities following a command ;;
;; was first proposed (to my knowledge) by Luis Esquivel in ;;
;; the following thread at TheSwamp: ;;
;; ;;
;; http://www.theswamp.org/index.php?topic=6455.0 ;;
;; ;;
;; I have expanded on this idea to undo, not only a deletion ;;
;; but all changes made to an object by storing the DXF data ;;
;; of the entity upon locking, and continuously reverting ;;
;; back to this data following modification. ;;
;; ;;
;; I would also like to thank Gilles Chanteau, since with ;;
;; aid of his 'True Rectangle' program, I learnt a great ;;
;; deal with regard to saving data in Drawing Dictionaries. ;;
;; Merci! ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;; Version 1.0 - 08-05-2011 ;;
;;------------------------------------------------------------;;
;;------------------------------------------------------------;;
;; Lock Objects - Locks Selected Unlocked Objects ;;
;;------------------------------------------------------------;;
(defun c:LockObjects
( / ss i j h e
) )
)
)
)
)
*handle*
)
)
)
)
)
)
)
)
(cons :vlr-commandended 'ObjectLockCallBack
) (cons :vlr-lispended 'ObjectLockCallBack
) )
)
)
)
)
)
)
(cons :vlr-beginsave 'ObjectLockSave
) )
)
)
(itoa j
) " Object(s) Locked, Total: " (itoa (length *handle
*)) " Locked." )
)
)
)
)
;;------------------------------------------------------------;;
;; Unlock Objects - Unlocks Selected Locked Objects ;;
;;------------------------------------------------------------;;
(defun c:UnLockObjects
( / ss i j r
) )
)
)
)
)
*handle*
)
)
)
(itoa j
) " Object(s) Unlocked, Total: " (itoa (length *handle
*)) " Locked." )
)
)
)
(princ "\n--> No Objects Locked.") )
)
)
)
)
)
;;------------------------------------------------------------;;
;; Disable Lock - Unlocks Everything ;;
;;------------------------------------------------------------;;
(defun c:DisableLock
( / acdic dic
) )
)
)
)
)
(if (setq dic
(ObjectLockGetItem acdic
"ObjectLock")) )
(setq *handle
* nil *elist
* nil) )
;;------------------------------------------------------------;;
(defun ObjectLockCallBack
( a b
) )
)
*handle*
)
)
;;------------------------------------------------------------;;
(defun ObjectLockGetItem
( collection item
) )
)
)
item
)
)
;;------------------------------------------------------------;;
;; Saving ;;
;;------------------------------------------------------------;;
(defun ObjectLockSave
( a b
/ acdic dic xrec l
) )
)
(if (not (setq dic
(ObjectLockGetItem acdic
"ObjectLock"))) )
(if (not (setq xrec
(ObjectLockGetItem dic
"Handles"))) )
)
)
)
)
)
)
;;------------------------------------------------------------;;
;; Loading ;;
;;------------------------------------------------------------;;
(
)
)
)
(ObjectLockGetItem
)
"ObjectLock"
)
)
(setq xrec
(ObjectLockGetItem dic
"Handles")) )
)
)
)
)
(cons :vlr-commandended 'ObjectLockCallBack
) (cons :vlr-lispended 'ObjectLockCallBack
) )
)
(cons :vlr-beginsave 'ObjectLockSave
) )
)
)
)
)
)
)
;;------------------------------------------------------------;;
;; End of File ;;
;;------------------------------------------------------------;;