Author Topic: Remove object reactor  (Read 2550 times)

0 Members and 1 Guest are viewing this topic.

Lupo76

  • Bull Frog
  • Posts: 343
Remove object reactor
« 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.
« Last Edit: March 08, 2012, 10:46:56 AM by Lupo76 »

BlackBox

  • King Gator
  • Posts: 3770
Re: Remove object reactor
« Reply #1 on: March 08, 2012, 09:07:24 AM »
Look into the vlr-Remove function.  :wink:
"How we think determines what we do, and what we do determines what we get."

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Remove object reactor
« Reply #2 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  :-)


BlackBox

  • King Gator
  • Posts: 3770
Re: Remove object reactor
« Reply #3 on: March 08, 2012, 10:15:55 AM »
Great point, Lee. :beer:
"How we think determines what we do, and what we do determines what we get."

Lupo76

  • Bull Frog
  • Posts: 343
Re: Remove object reactor
« Reply #4 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?

Lupo76

  • Bull Frog
  • Posts: 343
Re: Remove object reactor
« Reply #5 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: