Reactor Callback Events

AutoCAD AutoLISP & Visual LISP

 
Reactor Callback Events
 
 
 

For each reactor type there are a number of events that can cause the reactor to notify your application. These events are known as callback events, because they cause the reactor to call a function you associate with the event. For example, when you issue the Save command to save a drawing, a :vlr-beginSave event occurs. When you complete the save process, a :vlr-saveComplete event occurs. In designing a reactor-based application, it is up to you to determine the events you are interested in, and to write the callback functions to be triggered when these events occur.

The vlr-reaction-names function returns a list of all available events for a given reactor type:

(vlr-reaction-names reactor type)

For example, the following command returns a list of all events related to Object reactors:

$ (vlr-reaction-names
:VLR-Object-Reactor)
(:VLR-cancelled :VLR-copied :VLR-erased :VLR-unerased :VLR-goodbye :VLR-openedForModify :VLR-modified :VLR-subObjModified :VLR-modifyUndone :VLR-modifiedXData :VLR-unappended :VLR-reappended :VLR-objectClosed)
NoteIf this or any other vlr-* command fails with a “no function definition” message, you may have forgotten to call vl-load-com, the function that loads AutoLISP reactor support functions.

You can print out a list of all available reactor events, sorted by reactor type, by loading and running the following code in VLISP:

(defun print-reactors-and-events ()
  (foreach rtype (vlr-types)
    (princ (strcat "\n" (vl-princ-to-string rtype)))
    (foreach rname (vlr-reaction-names rtype)
      (princ (strcat "\n\t" (vl-princ-to-string rname)))))
  (princ))

The AutoLISP Reference lists each event available for a reactor type. For each reactor type, you can find this information by looking up the description of the function you use to define a reactor of that type. These functions have the same name as the reactor type, minus the leading colon. For example, vlr-acdb-reactor creates a database reactor, vlr-toolbar-reactor creates a toolbar reactor, and so on.