Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Simple Command Reactor

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
631 Views, 7 Replies

Simple Command Reactor

Hi,
I am a freebee to reactors. Could anybody help me write a simple reactor to command "Boundary"?
All I want to do is place a message in the command line: "Boundary finished running" after "Boundary" command finishes running.
Thanks,
Mike
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

;;;-------------------------------------------------------------------------
--------------------
(or *CmdReactor*
(setq *CmdReactor*
(VLR-Command-Reactor nil '((:VLR-commandWillStart .
BrandName_CmdReactor:WillStart)
(:VLR-commandEnded .
BrandName_CmdReactor:Ended)
(:VLR-commandCancelled .
BrandName_CmdReactor:Canceled)
))))


;;;-------------------------------------------------------------------------
--------------------
(defun BrandName_CmdReactor:WillStart (Reactor-Object Command-List) ;;;
Reactor Will Start
;;; Some events here. Since you don't have any hold it for future use
(princ)
)


;;;-------------------------------------------------------------------------
--------------------
(defun BrandName_CmdReactor:Ended (Reactor-Object Command-List) ;;; Reactor
Ended
(Boundary_finished_running Reactor-Object Command-List)
(princ)
)


;;;-------------------------------------------------------------------------
--------------------
(defun BrandName_CmdReactor:Canceled (Reactor-Object Command-List) ;;;
Reactor Canceled
;;; Some events here. Since you don't have any hold it for future use
(princ)
)


;;;-------------------------------------------------------------------------
--------------------
(defun Boundary_finished_running (Reactor-Object Command-List)
(and (member "BOUNDARY" Command-List)
(alert "Boundary finished running"))
(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
))
)












wrote in message news:4813841@discussion.autodesk.com...
> Hi,
> I am a freebee to reactors. Could anybody help me write a simple reactor
to command "Boundary"?
> All I want to do is place a message in the command line: "Boundary
finished running" after "Boundary" command finishes running.
> Thanks,
> Mike
Message 3 of 8
Anonymous
in reply to: Anonymous

Gaspar,
Thanks a lot! That works great. Do reactors work only with AutoCAD commands or could be used for lisp routines as well?
Thanks,
Mike
Message 4 of 8
Anonymous
in reply to: Anonymous

Hi Mike,


If you wanted to do something associated with running a program (written in
any language - not just lisp) why not write it into the program?


It would seem adding a reactor into the program would be like saying:
Am I running ?
If I am I must do something ?


--




Laurie Comerford
CADApps
www.cadapps.com.au




wrote in message news:4814228@discussion.autodesk.com...
> Gaspar,
> Thanks a lot! That works great. Do reactors work only with AutoCAD
commands or could be used for lisp routines as well?
> Thanks,
> Mike
Message 5 of 8
Anonymous
in reply to: Anonymous

When a command (sendcommand) is sent to AutoCAD from a dll, the dll is not going to wait for the command to stop running. They are two different processes. In fact, the dll will finish running before a command in AutoCAD is executed. What if I wanted to use the results of sendcommand later in the dll code? The only way I can do that is to know when the sendcommand is finished executing and then continie running my code.
That is basically why I need to know how to use reactors. Message was edited by: mgrigoriev
Message 6 of 8
Anonymous
in reply to: Anonymous

Here is a little sample about the lisp routines....


(defun commandwillstart (reactor params / acad_obj)
(if (= (car params) "EATTEDIT")
(vla-eval (setq acad_obj (vlax-get-acad-object))
(strcat "Sendkeys \"{ESC}\""))))


(defun lispwillstart (reactor params / acad_obj)
(if (= (car params) "(C:FC)")
(vla-eval (setq acad_obj (vlax-get-acad-object))
(strcat "Sendkeys \"{ESC}\""))))


(if (not cmd_cancel_editor_reactor)
(setq cmd_cancel_editor_reactor
(vlr-editor-reactor
nil
'((:vlr-commandwillstart . commandwillstart)))))


(if (not cmd_cancel_lsp_reactor)
(setq cmd_cancel_lsp_reactor
(vlr-lisp-reactor
nil
'((:vlr-lispwillstart . lispwillstart)))))
Message 7 of 8
Anonymous
in reply to: Anonymous

I am sorry, you posted some code after MAKE SURE EXECUTE THIS IN THE END OF AUTOCAD SESSION. Where should I put this code?
Message 8 of 8
Anonymous
in reply to: Anonymous

Hi,


If I was writing a program that's worth protecting I wouldn't be using
Sendcommand - or if it was essential - I'd leave it till last in the
execution chain.


Also, although I haven't installed 2006 yet, I heard rumours Autodesk have
modified it to allow code with sendcommand to end before moving on. Check
the documentation when you get it.


--




Laurie Comerford
CADApps
www.cadapps.com.au


wrote in message news:4815000@discussion.autodesk.com...
> When a command (sendcommand) is sent to AutoCAD from a dll, the dll is not
going to wait for the command to stop running. They are two different
processes. In fact, the dll will finish running before a command in AutoCAD
is executed. What if I wanted to use the results of sendcommand later in the
dll code? The only way I can do that is to know when the sendcommand is
finished executing and then continie running my code.
> That is basically why I need to know how to use reactors.
>
> Message was edited by: mgrigoriev

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta