TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Andrea on October 18, 2011, 11:06:16 AM

Title: Reactor on PLOT
Post by: Andrea on October 18, 2011, 11:06:16 AM
Hi guys,...

I have some problem with reactor in AutoCAD 2011
for some reason, the CANCEL reactor do not work with PLOT command.

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

(defun *CancelCPLOT* (calling-reactor startcommandInfo / )
  (alert "Plot Cancelled")
)

(if cancelCPLOT (progn (vlr-remove cancelCPLOT)(setq cancelCPLOT nil)))
(setq cancelCPLOT (vlr-command-reactor nil '((:vlr-commandCancelled . *CancelCPLOT*))))

strange thing...
that when you cancel the PLOT command it use :vlr-commandEnded against :vlr-commandCancelled

any one have note this issue ?

Thanks.
Title: Re: Reactor on PLOT
Post by: Andrea on October 21, 2011, 09:37:56 AM
57 views and no suggestions ?
well,..I thougt you was better....LOL !  :)

ok,..just let sharing a workaround..

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


;;;;; ;;
;;;;; LOAD REACTEUR ;;
;;;;; ;;
(defun *startcplot* (calling-reactor startcommandinfo)
  (cond ((eq (car startcommandinfo) "PLOT") (alert "Start")))
)


(defun *endcplot* (calling-reactor startcommandinfo)
  (if (and (eq (getvar "diastat") 1)
           (eq (car startcommandinfo) "PLOT")
      )
    (alert "End")
    (alert "Cancelled")
  )
)



(defun loadcplotreactor ()
  ;;On command Start
  (if startcplot
    (progn (vlr-remove startcplot) (setq startcplot nil))
  )
  (setq startcplot (vlr-command-reactor nil
                                        '((:vlr-commandwillstart . *startcplot*))
                   )
  )
  ;;On command Ended
  (if endcplot
    (progn (vlr-remove endcplot) (setq endcplot nil))
  )
  (setq endcplot (vlr-command-reactor nil
                                      '((:vlr-commandended . *endcplot*))
                 )
  )
)

(loadcplotreactor)

I hope this will help some other..
have a good day all !
Title: Re: Reactor on PLOT
Post by: Xander on October 23, 2011, 08:27:55 PM
Andrea,

I've just done a quick little test and found the following:
-Cancelling through the plot dialog calls the ended reactor.
-Plotting through the transparent command pressing escape calls the cancelled reactor.

Code: [Select]
(SETQ *testreactor*
         (LIST
             (VLR-COMMAND-REACTOR
                 nil
                 '(
                   (:VLR-COMMANDCANCELLED . testing:cancelledreactor)
                   (:VLR-COMMANDFAILED . testing:failedreactor)
                   (:VLR-COMMANDENDED . testing:endedreactor)
                   (:VLR-COMMANDWILLSTART . testing:startingreactor)
                  )
             )
         )
)

(DEFUN testing:cancelledreactor (reactor arguments /)
    (PRINC "\nCANCELLED")
)
(DEFUN testing:failedreactor (reactor arguments /)
    (PRINC "\nFAILED")
)
(DEFUN testing:endedreactor (reactor arguments /)
    (PRINC "\nENDED")
)
(DEFUN testing:startingreactor (reactor arguments /)
    (PRINC "\nSTARTING")
)