To create an object reactor (AutoLISP/ActiveX)

Creates an object reactor that displays a message when the object is modified.

Note: ActiveX support in AutoLISP is limited to Windows only.
  1. Determine which object event to use for the reactor.
  2. Define the function that will be used as the callback for the reactor.
  3. Define the function that creates or gets the VLA-object in which you want to attach the reactor.
  4. Create the reactor; statement that creates the reactor object, assigns application-specific data, associates which VLA-objects that the reactor should work with, and specifies the callback function.
  5. Load, run, and test the AutoLISP code.

Example

  1. At the AutoCAD Command prompt, enter vlide.
  2. In Visual LISP, click File New File.
  3. In the new Visual LISP text editor window, enter the following
    ; Define the callback function to use for the reactor
    ; The following function prints a message with the circle’s radius
    (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))
        )
      )
    )
    
    ; Create a variable to hold the circle object that
    ; will be used as the owner of the reactor
    (setq myCircle
      ; Prompt for the center point and radius:
      (progn
        (setq ctrPt (getpoint "\nCircle center point: ")
                 radius (distance ctrPt (getpoint ctrpt "\nRadius: "))
        )
    
        ; Add a circle to the drawing model space. Nest the function
        ; calls to obtain the path to the current drawing's model
        ; space: AcadObject > ActiveDocument > ModelSpace
        (vla-addCircle
          (vla-get-ModelSpace
            (vla-get-ActiveDocument (vlax-get-acad-object))
          )
          (vlax-3d-point ctrPt)
          radius
        )
      )
    )
    
    ; Create the reactor and pass it the circle object, 
    ; application-specific data, and callback function.
    (if (= circleReactor nil)
      (setq circleReactor (vlr-object-reactor (list myCircle)
        "Circle Reactor" '((:vlr-modified . print-radius))))
    )
  4. Click Tools Load Text in Editor.
  5. In the AutoCAD drawing window, specify a center point and radius for the circle.
  6. After the circle is created, select it to displays its grips. Click one of the outer grips to change the circle’s radius.

    You should see a message after the STRETCH option’s prompt that is similar to the following:

    Specify stretch point or [Base point/Copy/Undo/eXit]: The radius is 3.75803