Jump to content

Make Block became read only


MMS

Recommended Posts

Can we create some block where we can use just at local machine. If the block is opened in other machine, user can't copy block or can't print the block ?

Maybe we can create some coding ?

Link to comment
Share on other sites

Hi lee,

 

This code just only for one session / temporary. If we closing the drawing and opening again the code is not effect. So could you tell me how to create code if we close and open again the code it's still work.

 

 

(defun c:LockObjects ( / ss )
 (vl-load-com)
 ;; © Lee Mac 2010
 
 (if (setq ss (ssget "X" (list(cons 0 "insert"))))
   (
     (lambda ( i / e hand )
       (while (setq e (ssname ss (setq i (1+ i))))
         (if
           (not
             (vl-position
               (setq hand
                 (vla-get-Handle (vlax-ename->vla-object e))
               )
               *locked*
             )
           )
           (setq *locked* (cons hand *locked*))
         )
       )
       (if
         (not
           (vl-some
             (function
               (lambda ( reactor )
                 (eq "ObjectLock" (vlr-data reactor))
               )
             )
             (cdar (vlr-reactors :vlr-editor-reactor))
           )
         )
         (vlr-editor-reactor "ObjectLock"
           (list
             (cons :vlr-commandEnded 'ObjectLockCallBack)
           )
         )
       )
     )
     -1
   )
 )
 (princ)
)

(defun c:UnLockObjects ( / ss )
 (vl-load-com)
 ;; © Lee Mac 2010

 (if *locked*
   
   (if (setq ss (ssget))
     (
       (lambda ( i / e hand )
         (while (setq e (ssname ss (setq i (1+ i))))
           (if (vl-position
                 (setq hand
                   (vla-get-Handle (vlax-ename->vla-object e))
                 )
                 *locked*
               )
             (setq *locked* (vl-remove hand *locked*))
           )
         )
       )
       -1
     )
   )
   (princ "\n** No Objects Locked **")
 )

 (princ)
)

(defun c:DisableLock ( / reactor )
 (vl-load-com)
 ;; © Lee Mac 2010
 
 (if
   (setq reactor
     (vl-some
       (function
         (lambda ( reactor )
           (if (eq "ObjectLock" (vlr-data reactor)) reactor)
         )
       )
       (cdar (vlr-reactors :vlr-editor-reactor))
     )
   )
   (vlr-remove reactor)
   (princ "\n** Object Lock not Running **")
 )

 (princ)
)

(defun ObjectLockCallBack ( reactor arguments )
 
 (if (wcmatch (strcase (car arguments)) "ERASE,EXPLODE")
   (mapcar
     (function
       (lambda ( handle )
         (or (entget (handent handle)) (entdel (handent handle)))
       )
     )
     *locked*
   )
 )
 (princ)
)

 

Thanks,

 

MMS

Link to comment
Share on other sites

Yes, the reactor/information is lost when the document is closed.

 

To make the reactor function between sessions, you would need to store the entity handle information in the drawing, perhaps in a dictionary/xdata. Then either rebuild the transcient reactor, or use a persistent reactor ( I would advise against that ).

Link to comment
Share on other sites

Yes, the reactor/information is lost when the document is closed.

 

To make the reactor function between sessions, you would need to store the entity handle information in the drawing, perhaps in a dictionary/xdata. Then either rebuild the transcient reactor, or use a persistent reactor ( I would advise against that ).

 

Could you tell me where I can find the tutorial about transcient reactor / persistent reactor ?

 

Thanks

Link to comment
Share on other sites

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