Defining Object Reactor Callback Functions

AutoCAD AutoLISP & Visual LISP

 
Defining Object Reactor Callback Functions
 
 
 

Unlike other AutoCAD reactors, object reactors are attached to specific AutoCAD entities (objects). When you define an object reactor, you must identify the entity the reactor is to be attached to. So callback functions for object reactors must be defined to accept three arguments:

  • The first argument identifies the object that fired the notification.
  • The second argument identifies the Reactor object that called the function.
  • The third argument is a list of parameters specific to the callback condition.

For example, the following code defines a callback function named print-radius. This function can be used to print the radius of a circle:

(defun print-radius (notifier-object reactor-object parameter-list)
  (vl-load-com)
  (cond
    (
     (vlax-property-available-p
       notifier-object
       "Radius"
     )
     (princ "The radius is ")
     (princ (vla-get-radius notifier-object))
    )
  )
)

Note that the code uses the vlax-property-available-p function to verify that the drawing object that notified this function contains a radius property.