I made an attempt to create a "Document Reactor" that would automatically run when the user switches between drawing files that have been already opened. However, it appears that as the user switches from one drawing to another several times the reactor will fire multiple times when you switch to a drawing, not just once.
It would be greatly appreciated if anyone can look at the sample code below and identify what I have done incorrectly......!
####Start Code
(vl-load-com)
(setq mac_documentbecamecurrent_reactor nil
mac_reactors_list nil
mac_item nil
mac_reactor nil
)
(if (setq mac_reactors_list (vlr-reactors :vlr-docmanager-reactor))
(progn (foreach mac_item mac_reactors_list
(if (= (vlr-data (cadr mac_item)) "MAC-DOCUMENTBECAMECURRENT-REACTOR")
(setq mac_documentbecamecurrent_reactor (cadr mac_item))
)
)
(if mac_documentbecamecurrent_reactor
(if (= (vlr-added-p mac_documentbecamecurrent_reactor) nil)
(vlr-add mac_documentbecamecurrent_reactor)
)
(setq mac_reactor (vlr-docmanager-reactor
"MAC-DOCUMENTBECAMECURRENT-REACTOR"
'((:vlr-documentbecamecurrent .
mac-reactor-documentbecamecurrent))
)
)
)
)
(setq mac_reactor (vlr-docmanager-reactor
"MAC-DOCUMENTBECAMECURRENT-REACTOR"
'((:vlr-documentbecamecurrent . mac-reactor-documentbecamecurrent))
)
)
)
(setq mac_documentbecamecurrent_reactor nil
mac_reactors_list nil
mac_item nil
mac_reactor nil
)
(defun mac-reactor-documentbecamecurrent (mac_reactor mac_info /)
(alert "Reactor has run")
(Princ)
)
#####End Code
Thank you in advance for any assistance.
Regards,
Vince
<edit: code tags added>