TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Lupo76 on March 08, 2012, 08:42:00 AM

Title: Remove object reactor
Post by: Lupo76 on March 08, 2012, 08:42:00 AM
Hello everyone,
I used the following code to add a reactor object:

Code: [Select]
                  (setq collReactor
                    (vlr-object-reactor (list (vlax-ename->vla-object ogg)) "NAMEAP"
                      '(
                        (:vlr-modified . reactor_coll)
                        (:vlr-objectClosed . reactor_endcoll)
                       )
                    )
                  )
                  (vlr-pers collReactor)


Now I would like to remove this reactor to some objects, while others do not.
How can I do?
Thanks in advance.
Title: Re: Remove object reactor
Post by: BlackBox on March 08, 2012, 09:07:24 AM
Look into the vlr-Remove (http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ff1a32d8d10ebc6b7ccc-677d.htm) function.  :wink:
Title: Re: Remove object reactor
Post by: Lee Mac on March 08, 2012, 09:23:22 AM
I'm guessing that you want to remove the entire Object Reactor, but from your comment:

Now I would like to remove this reactor to some objects, while others do not.

You may also want to look into the vlr-owner-remove function too  :-)

Title: Re: Remove object reactor
Post by: BlackBox on March 08, 2012, 10:15:55 AM
Great point, Lee. :beer:
Title: Re: Remove object reactor
Post by: Lupo76 on March 08, 2012, 10:36:52 AM
You may also want to look into the vlr-owner-remove function too  :-)

I tried to write

Code: [Select]
(setq ogg (car (entsel)))
(vlr-owner-remove collReactor (vlax-ename->vla-object ogg))

but does not work.
Can you give me some advice?
Title: Re: Remove object reactor
Post by: Lupo76 on March 08, 2012, 12:26:42 PM
If you can help someone ....

I found this code that does exactly what I ask:  :-)

Code: [Select]
(defun c:remo2 ( / allReactorsLst obj removeLst)
  (vl-load-com)
  (setq obj (vlax-ename->vla-object (car (entsel))))
  (mapcar
    '(lambda (a / ownLst)
      (setq ownLst (vlr-owners a))
      (cond
        ((and (member obj ownLst) (= (length ownLst) 1))
          (vlr-remove a)
        )
        ((member obj ownLst)
          (vlr-owner-remove a obj)
        )
      )
    )
    (apply 'append (mapcar 'cdr (vlr-reactors :vlr-object-reactor)))
  )
  ;(setq allReactors (apply 'append (mapcar 'cdr (vlr-reactors))))
  ;(mapcar 'vlr-remove allReactors) ; temporarily disable all reactors
  ;(vla-delete obj)
  ;(mapcar 'vlr-add allReactors)
  ;(princ)
)

I removed the last lines, because the object erased and generated exception.

I had a doubt: first to erase an object from the drawingnecessary to remove the reactor? If yes: why?    :oops: