Author Topic: Restricting copy command  (Read 2310 times)

0 Members and 1 Guest are viewing this topic.

subbup

  • Guest
Restricting copy command
« on: February 01, 2005, 05:32:07 AM »
How can we restrict user copying an entity in particular layer.

hendie

  • Guest
Restricting copy command
« Reply #1 on: February 01, 2005, 06:13:36 AM »
You would have to use a reactor to intercept the copy command, and check the layer of the object being copied, and depending upon the layer found, continue the command or cancel it. I don't know how that would work with the Dropgeom command though.
can't you just lock the layer ?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Restricting copy command
« Reply #2 on: February 01, 2005, 10:08:59 AM »
I have given this some considerable thought and I have to agree with hendie. You would have to utilize a reactor, that would prevent an object from being copied based upon it's layer, but you should also know that there are other methods by which an object can be copied even if you completely disable the copy command.

The user could mirror the object twice and create an exact replica, if it was layer dependent, simply put the object on another layer and copy at will, dropgeom, array, block/insert/explode, and more ways I am sure.

It would depend entirely upon your intent for not wanting an object copied and to what degree you would need to protect that particular object.

If your intent is to prevent the copying of specific pieces of a drawing, then a reactor combined with xdata will do the trick almost flawlessly, except it will be difficult to restrict user defined programs unless they are designed to interact with the objects in a manner consistent with the no copy rule.

I would suspect a way to handle it would be something like so:

register all items
retrieve largest handle from all objects on protected layer
grab entlast
wait for user to enter command
grab entlast
if entlast is not the same as before then check for xdata
if the object has xdata that is marked for no copying, delete the object
otherwise continue
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Restricting copy command
« Reply #3 on: February 01, 2005, 11:06:49 AM »
I created this routine to make filtered selection set based on picked layers.
It's not what you asked for but speeds up the layer filter process.
Then use any command that allows a preselected selection set.
If the command you use after clears the selection set just enter P for previous
and all is well.

Code: [Select]
;;=============================================================
;;     Sel.lsp by Charles Alan Butler
;;            Copyright 2004
;;   by Precision Drafting & Design All Rights Reserved.
;;   Contact at ab2draft@TampaBay.rr.com
;;
;;    Version 1.0 Beta  July 23,2004
;;
;;   Creates a selection set of objects on a layer(s)
;;   User picks objects to determine the layer(s)
;;   Then User selects objects for ss or presses enter to
;;   get all objects on the selected layer(s)
;;   You may select the selection set before starting this
;;   routine. Then select the layers to keep in the set
;;=============================================================
(defun c:sel (/ ent lay ss lay:lst lay:prompt ss:first)
  ;;  get anything already selected
  (setq ss:first (cadr(ssgetfirst))
        ss (ssadd))

  (setq lay:lst '())
  ;;  Get user selected layers
  (if ss:first
    (setq lay:prompt "\nSelect the object to choose layers to keep.")
    (setq lay:prompt "\nSelect object for layer filter.")
  )
  (while (setq ent (entsel lay:prompt))
    (setq lay:lst
           (cons (setq lay (cdr(assoc 8 (entget (car ent))))) lay:lst))
    (prompt (strcat "\n*-* Selected Layer -> " lay))
  )
         
  (if (> (length lay:lst) 0); got layers to work with
    (progn
      (setq lay "")
      (foreach itm  lay:lst ; combine lay names into one , del string
        (setq lay (strcat lay itm ",")))
      (setq lay (substr lay 1 (1- (strlen lay)))); remove the last ,
      (if ss:first ; ALREADY GOT SELECTION SET
        (while (setq ent (ssname ss:first 0))
          (if (member (cdr(assoc 8 (entget ent))) lay:lst)
            (ssadd (ssname ss:first 0) ss)
          )
          (ssdel (ssname ss:first 0) ss:first)
        )
        (progn ; else get a selection set to work with
          (prompt (strcat "\nOK >>--> Select objects for Selection set or "
                          "ENTER for All objects on layer(s) " lay))
          ;;  get objects using filter with user select
          (if (null (setq ss (ssget (list (cons 8 lay)))))
            ;; or get ALL objects using filter
            (setq ss (ssget "_X" (list (cons 8 lay))))
          )
        )
      )
      (if (> (sslength ss) 0)
        (progn
          (prompt (strcat "\n" (itoa (sslength ss))
                      " Object(s) selected on layer(s) " lay
                      "\nStart an ACAD command."))
          (sssetfirst nil ss)
        )
        (prompt "\n***  Nothing Selected  ***")
      )
    )
  )
  (princ)
)
(prompt "\nSelect on Layer loaded, Enter Sele to run.")
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.