Author Topic: Temporarily disable reactors  (Read 3299 times)

0 Members and 1 Guest are viewing this topic.

Lupo76

  • Bull Frog
  • Posts: 343
Temporarily disable reactors
« on: May 25, 2015, 09:58:10 AM »
Hello everyone,
there exists a function VLISP able to temporarily disable all the reactors?  :?
Obviously I need also the function that rehabilitates all reactors. ;-)

kpblc

  • Bull Frog
  • Posts: 396
Re: Temporarily disable reactors
« Reply #1 on: May 25, 2015, 10:13:44 AM »
If i undestand the question correctly: to remove reactors you can use vlr-remove or vlr-remove-all functions. But to restore your customized reactors you have to reload appropriate functions.
Sorry for my English.

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Temporarily disable reactors
« Reply #2 on: May 25, 2015, 10:22:01 AM »
As kpblc correctly states:

vlr-remove/vlr-remove-all to disable the reactors.

vlr-add to re-enable.

However, be sure to acquire the vla-objects representing the reactors prior to disabling them, as otherwise you will have no references to the reactors and consequently won't be able to re-enable them.

Also, if you are working with Object Reactors, be aware that you cannot disable the reactor from within its own callback function and you will also need to ensure that all owners are write-enabled, as otherwise you will not be able to modify the reactor (refer to this thread).

Lupo76

  • Bull Frog
  • Posts: 343
Re: Temporarily disable reactors
« Reply #3 on: May 25, 2015, 10:30:24 AM »
As kpblc correctly states:

vlr-remove/vlr-remove-all to disable the reactors.

vlr-add to re-enable.

However, be sure to acquire the vla-objects representing the reactors prior to disabling them, as otherwise you will have no references to the reactors and consequently won't be able to re-enable them.

Also, if you are working with Object Reactors, be aware that you cannot disable the reactor from within its own callback function and you will also need to ensure that all owners are write-enabled, as otherwise you will not be able to modify the reactor (refer to this thread).

I know these functions.
However I was looking for something that does not remove or add the reactors, but simply something that makes them temporarily inactive.

I explain my context:
I have many objects that have this reactor:
Code: [Select]
(defun reactor_endedit (notifier-object reactor-object parameter-list
   (if (/= (getvar "CMDNAMES") "MOVE")
      (progn
        ....
       )
   )
)

I put (if (/= (getvar "CMDNAMES") "MOVE") because I want that the reactor does not start when using the MOVE command.
However AutoCAD processes all objects, and when I have to move hundreds of objects this takes too long.


As I have already redefined the MOVE command for other needs, I wanted to put in the command code redefined something that allows you to disable all the reactors and then reactivate them.

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Temporarily disable reactors
« Reply #4 on: May 25, 2015, 10:54:00 AM »
I know these functions.
However I was looking for something that does not remove or add the reactors, but simply something that makes them temporarily inactive.

[reactor active] > vlr-remove > [reactor temporarily inactive] > vlr-add > [reactor active]

 :?


Lupo76

  • Bull Frog
  • Posts: 343
Re: Temporarily disable reactors
« Reply #5 on: May 25, 2015, 11:04:11 AM »
I know these functions.
However I was looking for something that does not remove or add the reactors, but simply something that makes them temporarily inactive.

[reactor active] > vlr-remove > [reactor temporarily inactive] > vlr-add > [reactor active]

 :?

Unfortunately it is not that simple.
Ok for (vlr-remove-all), but (vlr-add) requires disclosure of the objects, then you must use foreach or while etc.

I tried something simpler:
[reactor active] > (reactor-disable) > [reactor temporarily inactive] > (reactor-enable) > [reactor active]


Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Temporarily disable reactors
« Reply #6 on: May 25, 2015, 11:20:05 AM »
Unfortunately it is not that simple.
Ok for (vlr-remove-all), but (vlr-add) requires disclosure of the objects, then you must use foreach or while etc.

As noted earlier:
However, be sure to acquire the vla-objects representing the reactors prior to disabling them, as otherwise you will have no references to the reactors and consequently won't be able to re-enable them.

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Temporarily disable reactors
« Reply #7 on: May 25, 2015, 11:23:18 AM »
Here is a quick example to demonstrate the idea:
Code: [Select]
(setq active-reactors (apply 'append (mapcar 'cdr (vlr-reactors))))
(vlr-remove-all)

< ... do your stuff ... >

(foreach obj active-reactors (vlr-add obj))

Note that the above does not take into consideration the following:

Also, if you are working with Object Reactors, be aware that you cannot disable the reactor from within its own callback function and you will also need to ensure that all owners are write-enabled, as otherwise you will not be able to modify the reactor (refer to this thread).

Lupo76

  • Bull Frog
  • Posts: 343
Re: Temporarily disable reactors
« Reply #8 on: May 25, 2015, 12:29:01 PM »
Here is a quick example to demonstrate the idea:

Thanks!
Very interesting!
I was hoping for something more immediate, but whereas there is no, I will add the code you suggested  ;-)

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Temporarily disable reactors
« Reply #9 on: May 25, 2015, 01:16:56 PM »
Here is a quick example to demonstrate the idea:

I was hoping for something more immediate, but whereas there is no, I will add the code you suggested  ;-)

I'm not sure what you mean by 'something more immediate'?

But please note that the code I have posted is only an example and does not include any error trapping to account for the points I have noted above!

ChrisCarlson

  • Guest
Re: Temporarily disable reactors
« Reply #10 on: May 26, 2015, 08:08:17 AM »
Instead of disabling all reactors, wouldn't it be more efficient and less destructive to generate a list of the specific reactors you want temporarily disabled by adding them to a global list? I'm not sure if any of the express tools or built in AutoDesk lisp routines utilize reactors. Last thing I would want is to temporarily break a pre-configured routine.