Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jtoverka on February 11, 2020, 08:49:29 AM
Title: Object Reactors
Post by: jtoverka on February 11, 2020, 08:49:29 AM
Gentlemen,
I am developing an application for AutoCAD Electrical. These AutoCAD verticals have a limitation where you can't simply use standard AutoCAD commands if you don't how everything works with the vertical side. For example, if you delete a wire, the wire number needs to be deleted as well. This can be overlooked if you "hide" the wire number (hide means frozen).
So I am trying to use reactors for my problem. In xData, there are pointers to other objects in the drawing. If you delete the object, in some cases, those other pointers must be deleted as well. Especially panel footprints and their item balloons.
However, I can't seem to find a way to read the object being deleted, so I can find those pointers. The object is deleted prior to the reactor function being called.
Help is much appreciated!
Title: Re: Object Reactors
Post by: roy_043 on February 11, 2020, 09:51:58 AM
See here: https://www.theswamp.org/index.php?topic=52466.msg573976#msg573976
Title: Re: Object Reactors
Post by: ribarm on February 11, 2020, 10:03:52 AM
There is some related things for you to look for in this topic : https://www.cadtutor.net/forum/topic/68098-reactor-when-entity-copied-how-to-pass-the-ss
I just haven't posted there more codes, but I've mod. my version that operates like command functions - custom erase and custom copy like this :
But if you want to use built-in erase and copy or grip-edit (modify), you'll probably have to go with storing entity handles in global list for usage with Object Reactor... Here is version that does that with combination of Object and DeepClone Reactor :
This is all related with topic I gave you link at CadTutor site and IMHO, you should be able to find what you're looking for with using XDATA and entity HANDLES, but be aware that second code operates with global list and if list is altered in any way you may experience unpredicted behaviour... What is the main point as far as my investigation explains, the trick is in Object Reactor - when you want to add/remove owners, you should avoid using (vlr-owner-add) and (vlr-owner-remove) - this is buggy - you have to redefine Reactor with complete newly owner list like you are firstly defining it - AFAIK this is the only way to make it operate as desired IMHO...
HTH., M.R.
Title: Re: Object Reactors
Post by: jtoverka on February 11, 2020, 11:17:56 AM
Thank you,
There was a lot of useful information related to this topic there.
I ended up storing the attributes and xData as reactor data. Every time it is modified, I update the reactor data. Then if it is deleted, I use that reactor data instead of reading the object. It works like a charm!