Author Topic: Add Reactor to Popup Alert Lisp Routine  (Read 2001 times)

0 Members and 1 Guest are viewing this topic.

ROBBO

  • Bull Frog
  • Posts: 217
Add Reactor to Popup Alert Lisp Routine
« on: March 04, 2014, 05:58:14 AM »
What am I doing wrong? I am trying to add a reactor to activate Lee Mac's Popup subfunction with the qsave and save commands to alert user once a day when commands are activated, but unable to get it to work.

Any ideas would be much appreciated. Please see code below:

Code: [Select]
;;-------------------------=={ Popup }==----------------------;;
;;                                                            ;;
;;  Displays a pop-up message box prompting the user.         ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright 2012 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  title - Text to be displayed in the pop-up title bar      ;;
;;  msg   - Text content of the pop-up message box            ;;
;;  flags - Integer indicating icon & button appearance       ;;
;;          Reference: http://lee-mac.com/popup.html          ;;
;;------------------------------------------------------------;;
;;  Returns:  Integer indicating the button pressed to exit   ;;
;;------------------------------------------------------------;;
;;Reactor added by Robbo 2014-03-04
;;------------------------------------------------------------;;
(defun LM:Popup (callling-reactor
commandwillstart_list)

(alert
(car commandwillstart_list ))

(if (member (car commandwillstart_list)'("QSAVE" "SAVE"))
   
(progn
;;------------------------------------------------------------;;

(defun LM:Popup ( title msg flags / wsh res )
    (if (setq wsh (vlax-create-object "wscript.shell"))
        (progn
            (setq res (vl-catch-all-apply 'vlax-invoke-method (list wsh 'popup msg

0 title flags)))
            (vlax-release-object wsh)
            (if (null (vl-catch-all-error-p res))
                res
            )
        )
    )
)

(defun IWillOnlyRunOnceADay nil
;;------------------------------------------------------------;;
;;Popup text added by Robbo 2014-03-04
;;------------------------------------------------------------;;
(LM:Popup ".bak file Information" "Please Note. To avoid project directory

clutter, .bak files are saved in your C:\\Temp_Acad\\Backup directory\n \nYou

may notice the benign error '_qsave Unable to transmit selected drawing

file.'\nThis is just a notification stating the .bak file wasn't saved in the

'expected' location - nothing to worry about!" (+ 0 64 4096))
(princ)
)


(if
(not
(and
(setq date (getenv "LMAC_OnceADay"))
(= (fix (getvar 'DATE)) (atoi date))
)
)
(progn
(IWillOnlyRunOnceADay)
(setenv "LMAC_OnceADay" (itoa (fix (getvar 'DATE))))
)
)
(princ)
)
)
)

Many thanks in advance, Robbo.
The only thing to do with good advice is to pass it on.
It is never of any use to oneself.

Oscar Wilde
(1854-1900, Irish playwright, poet and writer)

ronjonp

  • Needs a day job
  • Posts: 7327
Re: Add Reactor to Popup Alert Lisp Routine
« Reply #1 on: March 04, 2014, 08:24:35 AM »
Try something like this .You have to define the command reactor before you can call it.



Code: [Select]
;; COMMAND REACTOR
(or *commandreactors*
    (setq *commandreactors* (vlr-command-reactor nil '((:vlr-commandwillstart . strtcmd))))
)


(defun strtcmd (calling-reactor strtcmdinfo / date)
  (if (wcmatch (car strtcmdinfo) "*SAVE*")
    (progn
      (defun lm:popup (title msg flags / wsh res)
(if (setq wsh (vlax-create-object "wscript.shell"))
  (progn
    (setq res (vl-catch-all-apply 'vlax-invoke-method (list wsh 'popup msg 0 title flags)))
    (vlax-release-object wsh)
    (if (null (vl-catch-all-error-p res))
      res
    )
  )
)
      )
      (if (not (and (setq date (getenv "LMAC_OnceADay")) (= (fix (getvar 'date)) (atoi date))))
(progn
  (lm:popup
    ".bak file Information"
    (strcat
      "Please Note. To avoid project directory clutter, .bak files are saved in your C:\\Temp_Acad\\Backup directory"
      "\nYou may notice the benign error '_qsave Unable to transmit selected drawing file."
      "\nThis is just a notification stating the .bak file wasn't saved in the 'expected' location - nothing to worry about!"
    )
    (+ 0 64 4096)
  )
  (setenv "LMAC_OnceADay" (itoa (fix (getvar 'date))))
)
      )
      (princ)
    )
  )
)

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

ROBBO

  • Bull Frog
  • Posts: 217
Re: Add Reactor to Popup Alert Lisp Routine
« Reply #2 on: March 04, 2014, 08:54:26 AM »
Thank you ronjonp. Worked a treat!

As you can tell I am new to lisp, but never too old to learn!  :wink:

Cheers, Robbo
The only thing to do with good advice is to pass it on.
It is never of any use to oneself.

Oscar Wilde
(1854-1900, Irish playwright, poet and writer)

ronjonp

  • Needs a day job
  • Posts: 7327
Re: Add Reactor to Popup Alert Lisp Routine
« Reply #3 on: March 04, 2014, 08:59:09 AM »
Glad to help  :)

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC