TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Guest on October 09, 2007, 11:53:18 AM

Title: My First Reactor (crash and burn)
Post 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?

Code: [Select]
; 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)
Title: Re: My First Reactor (crash and burn)
Post by: T.Willey on October 09, 2007, 12:13:41 PM
vlr-beginSave is not a command reactor, it is of type 'vlr-dwg-reactor' that is why it doesn't work in your code.
Title: Re: My First Reactor (crash and burn)
Post by: ASMI on October 09, 2007, 02:03:36 PM
Or vlr-editor-reactor event.

May be simply (VLR-Remove-All), and (setq xxxReactor nil) for each reactor variable?
Title: Re: My First Reactor (crash and burn)
Post by: Guest on October 09, 2007, 02:04:28 PM
Or vlr-editor-reactor event.

May be simply (VLR-Remove-All), and (setq xxxReactor nil) for each reactor variable?
:-o :?
Title: Re: My First Reactor (crash and burn)
Post by: ASMI on October 10, 2007, 02:04:26 AM
> Matt W

What so wonder to you?

Standard way to create reactor:

Code: [Select]
(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:

Code: [Select]
(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

Code: [Select]
(vlr-remove-all)

to remove all reactors at once (not good way)

and

Code: [Select]
(setq reactorVariable1 nil)
.................................
(setq reactorVariableN nil)

to reset all reactor variables.

You also can use (vlr-reactors) to get information about all working reactors.