TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Guest on October 09, 2007, 11:53:18 AM
-
When I load the following I get this: invalid reaction name: :VLR-beginSave
Yet other SAVE reactor code I've seen has had VLR-beginSave in it. So why doesn't AutoCAD like it in my code?
; http://discussion.autodesk.com/thread.jspa?messageID=4814195
(or *CmdReactor*
(setq *CmdReactor*
(VLR-Command-Reactor
nil
'((:VLR-commandWillStart . BrandName_CmdReactor:WillStart)
(:VLR-commandEnded . BrandName_CmdReactor:Ended)
(:VLR-commandCancelled . BrandName_CmdReactor:Canceled)
(:VLR-BeginSave . MyCmdSave)))))
(defun MyCmdSave (Reactor-Object Command-List *activedoc*)
(setq *activedoc* (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))
(vla-sendcommand *activeacaddoc* "properties ") ; Just a test to make sure it worked
(princ)
)
;_ MAKE SURE EXECUTE THIS IN THE END OF AUTOCAD SESSION
(defun BrandName_CleanReactors ()
(setq *CmdReactor* nil)
(mapcar 'VLR-Remove-All
'(:VLR-AcDb-Reactor :VLR-Editor-Reactor :VLR-Linker-Reactor
:VLR-Object-Reactor :VLR-Command-Reactor :VLR-DeepClone-Reactor
:VLR-DocManager-Reactor :VLR-DWG-Reactor :VLR-DXF-Reactor
:VLR-Editor-Reactor :VLR-Insert-Reactor :VLR-Linker-Reactor
:VLR-Lisp-Reactor :VLR-Miscellaneous-Reactor :VLR-Mouse-Reactor
:VLR-Object-Reactor :VLR-SysVar-Reactor :VLR-Toolbar-Reactor
:VLR-Undo-Reactor :VLR-Wblock-Reactor :VLR-Window-Reactor
:VLR-XREF-Reactor))
)
(princ)
-
vlr-beginSave is not a command reactor, it is of type 'vlr-dwg-reactor' that is why it doesn't work in your code.
-
Or vlr-editor-reactor event.
May be simply (VLR-Remove-All), and (setq xxxReactor nil) for each reactor variable?
-
Or vlr-editor-reactor event.
May be simply (VLR-Remove-All), and (setq xxxReactor nil) for each reactor variable?
:-o :?
-
> Matt W
What so wonder to you?
Standard way to create reactor:
(if(not recactorVariable)
(setq reactorVariable
(vlr-XXXXXX-reactor Data '((:vlr-Reaction1 . ReactionFunction1)
................................................
(:vlr-ReactionN . ReactionFunctionN))))
); end if
Each reactor has fixed set of events. Some reactos has the same events. For example both vlr-dwg-reactor and vlr-editor-reactor has event :vlr-beginClose.
To remove reactors you can use:
(vlr-remove reactorVariable)
(setq reactorVariable nil)
because after (vlr-remove reactorVariable) 'reactorVariable' not equal nil and you can't use (if(not reactorVariable) to restore reactor.
or
(vlr-remove-all)
to remove all reactors at once (not good way)
and
(setq reactorVariable1 nil)
.................................
(setq reactorVariableN nil)
to reset all reactor variables.
You also can use (vlr-reactors) to get information about all working reactors.