Creates an object reactor that displays a message when the object is modified.
Note: ActiveX support in AutoLISP is limited to Windows only.
- Determine which object event to use for the reactor.
- Define the function that will be used as the callback for the reactor.
- Define the function that creates or gets the VLA-object in which you want to attach the reactor.
- 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.
- Load, run, and test the AutoLISP code.
Example
- Create a new LSP file and 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)))) )
- Save the LSP file and then load it into AutoCAD.
- In the AutoCAD drawing window, specify a center point and radius for the circle.
- 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