Author Topic: how to password protect autocad table  (Read 2292 times)

0 Members and 1 Guest are viewing this topic.

Sam

  • Bull Frog
  • Posts: 201
how to password protect autocad table
« on: September 02, 2015, 09:35:21 AM »
dear all
how to password protect autocad table???
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

ChrisCarlson

  • Guest
Re: how to password protect autocad table
« Reply #1 on: September 02, 2015, 09:53:21 AM »
Have a gander here, shouldn't be too hard to incorporate a password.

Code - Auto/Visual Lisp: [Select]
  1. ;;---------------------=={ Object Lock }==--------------------;;
  2. ;;                                                            ;;
  3. ;;  Purely academic code demonstrating the ability to use     ;;
  4. ;;  reactors to prevent modification of a selection of        ;;
  5. ;;  objects, and furthermore retain such security between     ;;
  6. ;;  drawing sessions.                                         ;;
  7. ;;                                                            ;;
  8. ;;  The code is written for demonstration only since it quite ;;
  9. ;;  clearly isn't practical. The functionality can be         ;;
  10. ;;  matched by simply using a Locked Layer; and moreover      ;;
  11. ;;  don't get your hopes up in thinking that you can use this ;;
  12. ;;  code to prevent third party modification of your drawings ;;
  13. ;;  since the reactors need to be loaded before the lock is   ;;
  14. ;;  effective. And who's going to fall for that one... ;)     ;;
  15. ;;                                                            ;;
  16. ;;  The program uses two reactors: an Editor Reactor - to     ;;
  17. ;;  undo any modification of a selection of objects following ;;
  18. ;;  the completion of a command or LISP program; and a        ;;
  19. ;;  Drawing Reactor - to save the handles of the locked       ;;
  20. ;;  Objects in a dictionary so that the reactors may be       ;;
  21. ;;  rebuilt when the drawing is next opened.                  ;;
  22. ;;                                                            ;;
  23. ;;  The concept of 'undeleting' entities following a command  ;;
  24. ;;  was first proposed (to my knowledge) by Luis Esquivel in  ;;
  25. ;;  the following thread at TheSwamp:                         ;;
  26. ;;                                                            ;;
  27. ;;  http://www.theswamp.org/index.php?topic=6455.0            ;;
  28. ;;                                                            ;;
  29. ;;  I have expanded on this idea to undo, not only a deletion ;;
  30. ;;  but all changes made to an object by storing the DXF data ;;
  31. ;;  of the entity upon locking, and continuously reverting    ;;
  32. ;;  back to this data following modification.                 ;;
  33. ;;                                                            ;;
  34. ;;  I would also like to thank Gilles Chanteau, since with    ;;
  35. ;;  aid of his 'True Rectangle' program, I learnt a great     ;;
  36. ;;  deal with regard to saving data in Drawing Dictionaries.  ;;
  37. ;;  Merci!                                                    ;;
  38. ;;------------------------------------------------------------;;
  39. ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
  40. ;;------------------------------------------------------------;;
  41. ;;  Version 1.0    -    08-05-2011                            ;;
  42. ;;------------------------------------------------------------;;
  43.  
  44. ;;------------------------------------------------------------;;
  45. ;;  Lock Objects  -  Locks Selected Unlocked Objects          ;;
  46. ;;------------------------------------------------------------;;
  47.  
  48. (defun c:LockObjects ( / ss i j h e )  
  49.   (if (setq ss (ssget))
  50.     (progn
  51.       (repeat (setq j 0 i (sslength ss))
  52.         (if
  53.           (not
  54.             (member
  55.               (setq h
  56.                 (cdr
  57.                   (assoc 5
  58.                     (setq e
  59.                       (entget
  60.                         (ssname ss (setq i (1- i)))
  61.                       )
  62.                     )
  63.                   )
  64.                 )
  65.               )
  66.               *handle*
  67.             )
  68.           )
  69.           (setq *handle* (cons h *handle*) *elist* (cons e *elist*) j (1+ j))
  70.         )
  71.       )
  72.       (if
  73.         (not
  74.           (vl-some
  75.             (function
  76.               (lambda ( r )
  77.                 (eq "ObjectLock" (vlr-data r))
  78.               )
  79.             )
  80.             (cdar (vlr-reactors :vlr-editor-reactor))
  81.           )
  82.         )
  83.         (vlr-editor-reactor "ObjectLock"
  84.           (list
  85.             (cons :vlr-commandended 'ObjectLockCallBack)
  86.             (cons :vlr-lispended    'ObjectLockCallBack)
  87.           )
  88.         )
  89.       )
  90.       (if
  91.         (not
  92.           (vl-some
  93.             (function
  94.               (lambda ( r )
  95.                 (eq "ObjectLock" (vlr-data r))
  96.               )
  97.             )
  98.             (cdar (vlr-reactors :vlr-dwg-reactor))
  99.           )
  100.         )
  101.         (vlr-dwg-reactor "ObjectLock"
  102.           (list
  103.             (cons :vlr-beginsave 'ObjectLockSave)
  104.           )
  105.         )
  106.       )          
  107.       (princ
  108.         (strcat "\n"
  109.           (itoa j) " Object(s) Locked, Total: " (itoa (length *handle*)) " Locked."
  110.         )
  111.       )
  112.     )
  113.   )
  114.   (princ)
  115. )
  116.  
  117. ;;------------------------------------------------------------;;
  118. ;;  Unlock Objects  -  Unlocks Selected Locked Objects        ;;
  119. ;;------------------------------------------------------------;;
  120.  
  121. (defun c:UnLockObjects ( / ss i j r )
  122.   (if *handle*
  123.     (if (setq ss (ssget))
  124.       (progn
  125.         (repeat (setq j 0 i (sslength ss))
  126.           (if
  127.             (member
  128.               (setq h
  129.                 (cdr
  130.                   (assoc 5
  131.                     (setq e
  132.                       (entget
  133.                         (ssname ss (setq i (1- i)))
  134.                       )
  135.                     )
  136.                   )
  137.                 )
  138.               )
  139.               *handle*
  140.             )
  141.             (setq *handle* (vl-remove h *handle*) *elist* (vl-remove e *elist*) j (1+ j))
  142.           )
  143.         )
  144.         (princ
  145.           (strcat "\n"
  146.             (itoa j) " Object(s) Unlocked, Total: " (itoa (length *handle*)) " Locked."
  147.           )
  148.         )
  149.       )
  150.     )
  151.     (princ "\n--> No Objects Locked.")
  152.   )
  153.   (if (null *handle*)
  154.     (mapcar
  155.       (function
  156.         (lambda ( r )
  157.           (if (eq "ObjectLock" (vlr-data r)) (vlr-remove r))
  158.         )
  159.       )
  160.     )
  161.   )
  162.   (princ)
  163. )
  164.  
  165. ;;------------------------------------------------------------;;
  166. ;;  Disable Lock  -  Unlocks Everything                       ;;
  167. ;;------------------------------------------------------------;;
  168.  
  169. (defun c:DisableLock ( / acdic dic )
  170.   (mapcar
  171.     (function
  172.       (lambda ( r )
  173.         (if (eq "ObjectLock" (vlr-data r)) (vlr-remove r))
  174.       )
  175.     )
  176.   )
  177.   (setq acdic
  178.     )
  179.   )
  180.   (if (setq dic (ObjectLockGetItem acdic "ObjectLock"))
  181.     (vla-delete dic)
  182.   )
  183.   (setq *handle* nil *elist* nil)
  184.   (princ)
  185. )
  186.  
  187. ;;------------------------------------------------------------;;
  188.  
  189. (defun ObjectLockCallBack ( a b )
  190.   (mapcar
  191.     (function
  192.       (lambda ( h )
  193.         (or (entget (handent h)) (entdel (handent h)))
  194.       )
  195.     )
  196.     *handle*
  197.   )
  198.   (mapcar 'entmod *elist*)
  199.   (princ)
  200. )
  201.  
  202. ;;------------------------------------------------------------;;
  203.  
  204. (defun ObjectLockGetItem ( collection item )
  205.   (if
  206.     (not
  207.         (setq item
  208.           (vl-catch-all-apply 'vla-item (list collection item))
  209.         )
  210.       )
  211.     )
  212.     item
  213.   )
  214. )
  215.  
  216. ;;------------------------------------------------------------;;
  217. ;;                           Saving                           ;;
  218. ;;------------------------------------------------------------;;
  219.  
  220. (defun ObjectLockSave ( a b / acdic dic xrec l )
  221.   (if *handle*
  222.     (progn
  223.       (setq acdic
  224.         )
  225.       )
  226.       (if (not (setq dic (ObjectLockGetItem acdic "ObjectLock")))
  227.         (setq dic (vla-add acdic "ObjectLock"))
  228.       )
  229.       (if (not (setq xrec (ObjectLockGetItem dic "Handles")))
  230.         (setq xrec (vla-addxrecord dic "Handles"))
  231.       )
  232.       (vla-setxrecorddata xrec
  233.         (vlax-safearray-fill
  234.           (vlax-make-safearray vlax-vbinteger (cons 0 (1- (length *handle*))))
  235.           (repeat (length *handle*) (setq l (cons 1 l)))
  236.         )
  237.         (vlax-safearray-fill
  238.           (vlax-make-safearray vlax-vbvariant (cons 0 (1- (length *handle*))))
  239.           (mapcar '(lambda ( h ) (vlax-make-variant h vlax-vbstring)) *handle*)
  240.         )
  241.       )
  242.     )
  243.   )
  244.   (princ)
  245. )
  246.  
  247. ;;------------------------------------------------------------;;
  248. ;;                          Loading                           ;;
  249. ;;------------------------------------------------------------;;
  250.  
  251. (
  252.   (lambda ( / dic xrec typ val ) (vl-load-com)
  253.     (mapcar
  254.       (function
  255.         (lambda ( r )
  256.           (if (eq "ObjectLock" (vlr-data r)) (vlr-remove r))
  257.         )
  258.       )
  259.     )
  260.     (if
  261.       (and
  262.         (setq dic
  263.           (ObjectLockGetItem
  264.             (vla-get-dictionaries
  265.             )
  266.             "ObjectLock"
  267.           )
  268.         )
  269.         (setq xrec (ObjectLockGetItem dic "Handles"))
  270.         (progn (vla-getxrecorddata xrec 'typ 'val) val)
  271.       )
  272.       (if
  273.         (and
  274.           (setq *handle*
  275.             (vl-remove-if-not
  276.               (function
  277.                 (lambda ( h ) (entget (handent h)))
  278.               )
  279.               (mapcar 'vlax-variant-value (vlax-safearray->list val))
  280.             )
  281.           )
  282.           (setq *elist* (mapcar '(lambda ( h ) (entget (handent h))) *handle*))
  283.         )
  284.         (progn
  285.           (vlr-editor-reactor "ObjectLock"
  286.             (list
  287.               (cons :vlr-commandended 'ObjectLockCallBack)
  288.               (cons :vlr-lispended    'ObjectLockCallBack)
  289.             )
  290.           )
  291.           (vlr-dwg-reactor "ObjectLock"
  292.             (list
  293.               (cons :vlr-beginsave 'ObjectLockSave)
  294.             )
  295.           )
  296.         )
  297.       )
  298.     )
  299.   )
  300. )
  301.  
  302.  
  303. ;;------------------------------------------------------------;;
  304. ;;                         End of File                        ;;
  305. ;;------------------------------------------------------------;;


http://www.lee-mac.com/objectlock.html

ronjonp

  • Needs a day job
  • Posts: 7529
Re: how to password protect autocad table
« Reply #2 on: September 02, 2015, 10:56:06 AM »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Sam

  • Bull Frog
  • Posts: 201
Re: how to password protect autocad table
« Reply #3 on: September 03, 2015, 08:30:22 AM »
DEAR SIR,

THX BUT I WANT LOCK ONLY FORMULA OR COLUMN & ROW WITH PASSWORD, JUST LIKE EXCEL,,  IF POSSIBLE???
CADVALUT LOCK ALL TABLE
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

ChrisCarlson

  • Guest
Re: how to password protect autocad table
« Reply #4 on: September 03, 2015, 08:59:26 AM »
Oh, no. Not possible to have a password protected cell.

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: how to password protect autocad table
« Reply #5 on: September 03, 2015, 02:31:29 PM »
You could possibly create the table in Excel and use a Table Data Link to bring it into AutoCAD, but that's the only way that might work that I know of.