Reactors !!??

Hi, I'm having a terrible time trying to figure out reactors. I've read multiple explanations and posts. But still not there. Can someone please have a look at my code and tell me what I've got wrong ?

;load visual lisp
(vl-load-com)
(setq myDrawingReactor nil)
(defun c:MakeSaveAlert ()
;access the application
(setq AcadApp (vlax-get-acad-object))
;drill down to open drawing (document)
(setq AcadDoc (vla-get-activedocument AcadApp))
(princ (strcat "\nCurrent Drawing is: " (vl-prin1-to-string AcadDoc)))
(attachDrawingSaveReactor)
) ;CALLBACK FUNCTION. THIS IS CALLED BY THE REACTOR
(defun mySaveCallback (reactor-object event-info /)
(princ "\n--- DRAWING IS BEING SAVED ! ---")
(princ)
)
;ATTACH THE REACTOR
;creat a reactor (defun attachDrawingSaveReactor ( AcadDoc / )
(if (not myDrawingReactor)
(progn
;create a reactor
(setq myDrawingReactor (vlr-dwg-reactor (list AcadDoc) "MyDrawingSaveReactorKey" '((:vlr-beginsave . mySaveCallback))))
(princ "\nDrawing Save Reactor ATTACHED to the current drawing!")
)
(princ "\nDrawing Save Reactor is ALREADY active.")
)
)

Comments

  • I just fixed it.

    ;load visual lisp
    (vl-load-com)
    (setq myDrawingReactor nil)
    (defun c:MakeSaveAlert ()
    ;access the application
    (setq AcadApp (vlax-get-acad-object))
    ;drill down to open drawing (document)
    (setq AcadDoc (vla-get-activedocument AcadApp))
    (princ (strcat "\nCurrent Drawing is: " (vl-prin1-to-string AcadDoc)))
    (attachDrawingSaveReactor AcadDoc)
    ) ;CALLBACK FUNCTION. THIS IS CALLED BY THE REACTOR
    (defun mySaveCallback ()
    (princ "\n--- DRAWING IS BEING SAVED ! ---")
    (princ)
    )
    ;ATTACH THE REACTOR
    ;creat a reactor (defun attachDrawingSaveReactor ( AcadDoc / )
    (if (not myDrawingReactor)
    (progn
    ;create a reactor
    (setq myDrawingReactor (vlr-dwg-reactor (list AcadDoc) '((:vlr-beginsave . mySaveCallback))))
    (princ "\nDrawing Save Reactor ATTACHED to the current drawing!")
    )
    (princ "\nDrawing Save Reactor is ALREADY active.")
    )
    )

    Now it works. I'm starting to understand reactors….

  • Atomkraft? Nein danke!

  • Not sure what your trying to achieve but I have "close and save" as reactors that run a certain defun before the actual save or close is ran. The defun does a task specific to a client request, manipulating title blocks.