Hi
You may use this sample:
; = AcadDoc.lsp ===============================================================
;
; - Initialize ActiveX support
(vl-load-com)
;
; - Reactors ------------------------------------------------------------------
;
; - If not set, initialize DocManager-Reactor
(or Me:ReaDma
(setq Me:ReaDma (VLR-DocManager-Reactor
nil
'(
(:VLR-documentToBeDestroyed . MeDocToBeDestroyedCallbacks)
)
)
)
)
; - If not set, initialize Command-Reactor
(or Me:ReaCom
(setq Me:ReaCom (VLR-Command-Reactor
nil
'(
(:VLR-commandEnded . MeCommandEndedCallbacks)
)
)
)
)
;
; - Notifications -------------------------------------------------------------
;
; - CommandEnded notifications
(defun MeCommandEndedCallbacks (Rea Arg)
(MeDoCmdEndedStuff Arg)
(princ)
)
; - DocToBeDestroyed notifications
(defun MeDocToBeDestroyedCallbacks (Rea Arg)
(MeDoCloseStuff)
(princ)
)
;
; - Subs ----------------------------------------------------------------------
;
; - Command ended function
(defun MeDoCmdEndedStuff (Arg / CurCmd)
(setq CurCmd (strcase (car Arg)))
(cond
((wcmatch CurCmd "LAYOUT_CONTROL,MSPACE,PSPACE,VPMAX")
(princ "\nReactor callback fired...")
)
;;; other command ended dependent functions
)
(princ)
)
; - Reactor cleanup function
(defun MeDoCloseStuff ( / VarLst)
(setq VarLst (MeGetReaVars))
(mapcar 'VLR-remove (mapcar 'eval VarLst))
(mapcar '(lambda (l) (set l nil)) VarLst)
(princ)
)
; - Collect global reactor variables
(defun MeGetReaVars ( / RetVal)
(foreach memb (atoms-family 1)
(if (wcmatch (strcase memb) "ME:REA*")
(setq RetVal (cons memb RetVal))
)
)
(mapcar 'read RetVal)
)
(princ)
Cheers