Code Red > AutoLISP (Vanilla / Visual)

Why the pers reactor is not the original one??

(1/1)

LUCAS:
;;just a test to remove the pers reactor when object is erase.
;;
;;1.Use "ANG1" to make some pers reactor objects
;;2.erase some pers reactor objects
;;3.then "undo" ,the pers reactor still exist,but not the original one.
;;4.erase its again,will have a error message

;;Why the pers reactor is not the original one??

(vl-load-com)
(if (not PIANGLELINE)
  (setq   PIANGLELINE
    (vlr-pers
      (vlr-object-reactor
        NIL
        NIL
        '((:vlr-erased . OBJDEL))
      )
    )
  )
)

 ;|can't remove the owner of pers reactor
(defun OBJDEL (VLX1 VLX2 VLX3)
  (print (vlr-owners VLX2))
  (vlr-owner-remove PIANGLELINE VLX1)
  (print (vlr-owners VLX2))
  (print "objdel")
)|;

;;-------------that can remove the owner---------------
(defun OBJDEL (VLX1 VLX2 VLX3)
  (print (vlr-owners VLX2))
  (vlr-remove PIANGLELINE)
  (vlr-owner-remove PIANGLELINE VLX1)
  (vlr-add PIANGLELINE)
  (print (vlr-owners VLX2))
  (prompt "\nobjdel\n")
)

(defun C:ANG1 (/ SS N)
  (setq N 0)
  (if (setq SS (ssget))
    (repeat (sslength SS)
      (vlr-owner-add
   PIANGLELINE
   (vlax-ename->vla-object (ssname SS N))
      )
      (setq N (1+ N))
    )
  )
  (princ)
)

zoltan:
When an object is erased, the reactor should not be removed, but instead made non-persistant.  The reactor will stay active with no owner making callbacks.  That way, if the object is restored with UNDO or OOPS, the reactor can be made persistant again with the vlr:unerased callback.  If the drawing exits before the object is restored, the erased object is purged and the non-persistant reactor dies.

LUCAS:
Thanks you! That great! I had writing a purely pers reactor without any error。

Navigation

[0] Message Index

Go to full version