Author Topic: vlr-remove not removing Object Reactor inside Callback Function  (Read 8869 times)

0 Members and 1 Guest are viewing this topic.

LE3

  • Guest
Re: vlr-remove not removing Object Reactor inside Callback Function
« Reply #15 on: August 27, 2012, 02:02:22 PM »
not a help at all - but recall seeing this, back on vital lisp too - don't remember if i ever end up doing anything for all my vlisp-reactors code in the past.

glad you still having fun with a-vlisp - cheers!

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: vlr-remove not removing Object Reactor inside Callback Function
« Reply #16 on: August 27, 2012, 02:04:18 PM »
Cheers Luis  :-)

glad you still having fun with a-vlisp - cheers!

I've tried to overcome the addiction many a time, but LISP still has me hooked  8-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: vlr-remove not removing Object Reactor inside Callback Function
« Reply #17 on: August 27, 2012, 02:19:16 PM »
Thank you for your time testing it Phil, your results in 2013 and CAB's results in 2006 confirm my suspicions that these are indeed bugs present in most, if not all, versions of AutoCAD and its derivative programs.

Since LISP is no longer in development I very much doubt these issues will be fixed any time soon, though, at least we are now aware of them and can code around them.

Thanks  :-)

Can modifying the reactor status be viewed as modifying the object & therefore not allowed while in the callback function?  8-)
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.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: vlr-remove not removing Object Reactor inside Callback Function
« Reply #18 on: August 27, 2012, 02:32:13 PM »
Can modifying the reactor status be viewed as modifying the object & therefore not allowed while in the callback function?  8-)

Given the similar behaviour experienced when an owner object resides on a locked layer, that would be a very plausible explanation for this problem Alan. Though, the major underlying issue is that the vlr-remove function reports that the reactor has been removed successfully, instead of throwing an error, and as a result the reactor cannot then be removed by any means other than to close the drawing.

In conclusion:

When using Object Reactors:
  • Do not attempt to remove the reactor from within the reactor callback function.
  • Verify that all owner objects of an Object Reactor are write enabled before attempting to remove the reactor.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: vlr-remove not removing Object Reactor inside Callback Function
« Reply #19 on: August 27, 2012, 02:38:53 PM »
the reactor cannot then be removed by any means other than to close the drawing.
You can delete the object and recreate it.

Good detective work Lee.
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.


LE3

  • Guest

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: vlr-remove not removing Object Reactor inside Callback Function
« Reply #22 on: August 27, 2012, 05:40:50 PM »
the reactor cannot then be removed by any means other than to close the drawing.
You can delete the object and recreate it.

You could, but that wouldn't actually remove the Object Reactor, only set the erase flag on the owner object(s) - they would still be owners to the Object Reactor and the Reactor would still be active in the drawing, to demonstrate:

Code - Auto/Visual Lisp: [Select]
  1. Command: _circle
  2. Specify center point for circle or [3P/2P/Ttr (tan tan radius)]:
  3. Specify radius of circle or [Diameter]:
  4. Command: addreactor  ;; <-------------- Circle is now owner of Object Reactor
  5.  
  6. Select object:
  7. Command: _.erase 1 found ;; <-------------- Circle deleted
  8.  
  9. Callback Evaluated. ;; <-------------- Callback evaluated on deletion (modification) of circle
  10. Command: (vlr-owners object-reactor)
  11. (#<VLA-OBJECT IAcadCircle 0e81c314>) ;; <-------------- Circle still owner of Object Reactor after deletion

Good detective work Lee.

Cheers Alan, you too  :-)


LE3

  • Guest
Re: vlr-remove not removing Object Reactor inside Callback Function
« Reply #24 on: August 27, 2012, 07:58:36 PM »
played on this a little and maybe thinking a bit too and went to read the help...

Code - Auto/Visual Lisp: [Select]
- will disable the reactor(s) only.

and maybe could it be a good idea to test if it is enabled, before doing any work inside of the callback:
Code - Auto/Visual Lisp: [Select]
  1. (defun mycallback  (owner reactor params)
  2. (if (vlr-added-p reactor)

so, inside of the callback, one might want to check if the reactor was disabled? first, and that's what has been provided always, a way to disabled the reactors and enabled them for later use, this means that the reactors are still there, unless they are actually removed outside by other means using:

Code - Auto/Visual Lisp: [Select]

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: vlr-remove not removing Object Reactor inside Callback Function
« Reply #25 on: August 28, 2012, 06:37:24 AM »
Code - Auto/Visual Lisp: [Select]
- will disable the reactor(s) only.

and maybe could it be a good idea to test if it is enabled, before doing any work inside of the callback:
Code - Auto/Visual Lisp: [Select]
  1. (defun mycallback  (owner reactor params)
  2. (if (vlr-added-p reactor)

so, inside of the callback, one might want to check if the reactor was disabled?

I would agree, except that in this case vlr-remove / vlr-remove-all don't appear to disable the reactors if called from within the callback function, or if an owner is on a locked layer.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: vlr-remove not removing Object Reactor inside Callback Function
« Reply #26 on: August 28, 2012, 06:50:17 AM »
Yep, I think the issue is that object reactors are linked to objects using entity data (in this case a dictionary). And if you want to edit the entity data (i.e. remove the reactor) you need a write lock on that entity. But since the reactor fires, it already has a read-lock since it just read the data of the reactor. Therefore the write-lock cannot be obtained and the edit fails.

You might have to remove the reactor from somewhere else. I.e. when it has finished and the locks are released. Though where to do this I'm not sure - would have been a perfect place for a timer-reactor  :ugly:
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: vlr-remove not removing Object Reactor inside Callback Function
« Reply #27 on: August 28, 2012, 07:00:56 AM »
You might have to remove the reactor from somewhere else. I.e. when it has finished and the locks are released. Though where to do this I'm not sure...

Reply#7  :wink: