Author Topic: reactor triggered when Autocad is exiting  (Read 6538 times)

0 Members and 1 Guest are viewing this topic.

Amsterdammed

  • Guest
reactor triggered when Autocad is exiting
« on: May 28, 2005, 09:24:00 AM »
I need to write some accounting program that writes to a log file what the designers are doing during a day. In the end of the day they should be offered a dialog box with all the files they worked on this day and the editing time they spend.

So they can fill in what they did with the file and all this will be written to a Dbase in Excel (not everybody in our company has MS-Access).

My Question is if there is a reactor that is triggered by closing Acad. I tried with a command reactor and the command “quit”. Would work, but than you have to leave Acad by typing Quit, what nobody does.

Is there some smart solution??

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
reactor triggered when Autocad is exiting
« Reply #1 on: May 28, 2005, 08:05:26 PM »
Google or Google GROUPS for
vlr-beginClose Mishler OR Menzi OR Puckett OR Luis OR Schneider


The results will be equal to the best you will find anywhere
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
reactor triggered when Autocad is exiting
« Reply #2 on: May 29, 2005, 06:35:16 AM »
Hi Amsterdammed

I've prepared an AcadDoc.lsp sample to write into a logfile. The only thing you've to do is to add your code inside the 'MeWriteToLogFile' function.
Code: [Select]
;
; == AcadDoc.lsp ==============================================================
; Initialize a Document Reactor to write a logfile on closing a document.
; Copyright:
;   ©2005 MENZI ENGINEERING GmbH, Switzerland
; Notes:
;   - None
;
; - Initialize ActiveX support
(vl-load-com)
;
; - Reactors ------------------------------------------------------------------
;
; - If not set, initialize DocManager-Reactor
(or Me:ReaDma
 (setq Me:ReaDma (VLR-DocManager-Reactor
                  nil
                 '(
                   (:VLR-documentToBeDestroyed . MeDocToBeDestroyedCallbacks)
                  )
                 )
 )
)
;
; - Notifications -------------------------------------------------------------
;
; - DocToBeDestroyed notifications
(defun MeDocToBeDestroyedCallbacks (Rea Arg)
 (MeWriteToLogFile)
 (MeDoCloseStuff)
 (princ)
)
;
; - Subs ----------------------------------------------------------------------
;
; - Reactor cleanup function
(defun MeDoCloseStuff ( / VarLst)
 (setq VarLst (MeGetReaVars))
 (mapcar 'VLR-remove (mapcar 'eval VarLst))
 (mapcar '(lambda (l) (set l nil)) VarLst)
 (princ)
)
; - Collect global reactor variables
(defun MeGetReaVars ( / RetVal)
 (foreach memb (atoms-family 1)
  (if (wcmatch (strcase memb) "ME:REA*")
   (setq RetVal (cons memb RetVal))
  )
 )
 (mapcar 'read RetVal)
)
; - Write to logfile function
(defun MeWriteToLogFile ( / )
;;; Add yor 'WriteToLogFileCode'
 (princ)
)
 
(princ)
;
; == End AcadDoc.lsp ==========================================================


Cheers
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
reactor triggered when Autocad is exiting
« Reply #3 on: May 29, 2005, 07:40:17 AM »
hehehehe

.. Unless one of those Gentlemen write a specific routine for you. :)

.. and use  VLR-documentToBeDestroyed instead  :oops:
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
reactor triggered when Autocad is exiting
« Reply #4 on: May 29, 2005, 09:14:28 AM »
Quote from: Kerry Brown
Unless one of those Gentlemen write a specific routine for you.
Taking my standard sample, have done some modifications and voilà... :mrgreen:
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

Amsterdammed

  • Guest
reactor triggered when Autocad is exiting
« Reply #5 on: May 29, 2005, 10:26:20 AM »
Quote from: Kerry Brown
Google or Google GROUPS for
vlr-beginClose Mishler OR Menzi OR Puckett OR Luis OR Schneider


The results will be equal to the best you will find anywhere


Thank's.
I had to realise on Google that what i really want (to get an event on closing Autocad, not the drawings, this i allready covered) does no exist.

I wanted on the end of the working day (exit Acad) that a dialogbox appears.

I will have to get another way, I guess.

 :roll: [/quote]

Amsterdammed

  • Guest
reactor triggered when Autocad is exiting
« Reply #6 on: May 29, 2005, 10:29:57 AM »
Quote from: Kerry Brown
hehehehe

.. Unless one of those Gentlemen write a specific routine for you. :)

.. and use  VLR-documentToBeDestroyed instead  :oops:


Nice, yes. But that is what you get when you are lazy. :wink:

Amsterdammed

  • Guest
reactor triggered when Autocad is exiting
« Reply #7 on: May 29, 2005, 10:31:20 AM »
Quote from: Jürg Menzi
Quote from: Kerry Brown
Unless one of those Gentlemen write a specific routine for you.
Taking my standard sample, have done some modifications and voilà... :mrgreen:


Gruezzi in die Schwitz :D

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: reactor triggered when Autocad is exiting
« Reply #8 on: May 29, 2005, 11:09:01 AM »
Quote from: Amsterdammed
My Question is if there is a reactor that is triggered by closing Acad. I tried with a command reactor and the command “quit”. Would work, but than you have to leave Acad by typing Quit, what nobody does.

What do you mean by close? If you mean by clicking the terminate icon:



the quit event is still fired. Try it:

Code: [Select]
(if (/= 'VLR-Command-Reactor (type ReactorCommandWillStart))
    (setq ReactorCommandWillStart
        (vlr-command-reactor nil
           '((:vlr-commandWillStart . CallbackCommandWillStart))
        )
    )
)

(defun CallbackCommandWillStart ( reactor cmdInfo / cmdName )
    (cond
        (   (eq "QUIT" (setq cmdName (car cmdInfo)))
            (alert "When you press [ Ok ] AutoCAD will vanish.")
        )
    )
)

Note: I tested this rather quickly in AutoCAD 2006.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Amsterdammed

  • Guest
Re: reactor triggered when Autocad is exiting
« Reply #9 on: May 30, 2005, 07:45:09 AM »
Quote from: MP

Note: I tested this rather quickly in AutoCAD 2006.


Thank's MP  :roll:

I thought the same, the event is the same, only started by the button in the window's corner.

You are right, the code works in R2006, but not in R2002. So i will find out when our company makes the move to Acad 2006 (I have it already for development reasons, i'm considered as the one eyed in the "Kingdom of the blind" known as the Company I'm working for ). If it is in the near future, I'll be fine, otherwise I will try something with closing the last open drawing (a sign you wanna quit acad, too, i guess)


Thanks for the help, MP  :D

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
reactor triggered when Autocad is exiting
« Reply #10 on: May 30, 2005, 08:27:03 AM »
Perhaps you could hook into the documentToBeDestroyed event and fire your logging app when the documents count is 1. You may have to do some exprimentation with the count property to see when it truly represents the "AutoCAD is about to leave the building" event, notwithstanding the state of the sdi system variable.

Also, have you tried to find out if any command event is thrown when it's AutoCAD is terminating? Like --

Code: [Select]
(if (/= 'VLR-Command-Reactor (type ReactorCommandWillStart))
    (setq ReactorCommandWillStart
        (vlr-command-reactor nil
           '((:vlr-commandWillStart . CallbackCommandWillStart))
        )
    )
)

(defun CallbackCommandWillStart ( reactor cmdInfo / cmdName )
    (cond
        (   (eq "QUIT" (setq cmdName (car cmdInfo)))
            (alert "When you press [ Ok ] AutoCAD will vanish.")
        )
        (   cmdName
            (alert
                (strcat
                    "<"
                    cmdName
                    "> Command called."
                )    
            )
        )
    )
)

Hope this makes sense, just woke up and still kinda groggy.

Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
reactor triggered when Autocad is exiting
« Reply #11 on: May 30, 2005, 12:58:27 PM »
You might want to look into the VBA Event "BeginQuit". It fires when Acad is closed by any method, other than a crash...

Amsterdammed

  • Guest
reactor triggered when Autocad is exiting
« Reply #12 on: May 30, 2005, 01:05:58 PM »
Quote from: Jeff_M
You might want to look into the VBA Event "BeginQuit". It fires when Acad is closed by any method, other than a crash...


So i will have to do the whole thing in VBA ? :?:

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
reactor triggered when Autocad is exiting
« Reply #13 on: May 30, 2005, 02:51:12 PM »
Yes, I believe so. But don't be afraid to give it a try and ask lots of questions. There are plenty of folks here that can help you in that direction, too.

Michael, your code returns nothing if the "X" is clicked to close Acad2002 :?

Amsterdammed

  • Guest
reactor triggered when Autocad is exiting
« Reply #14 on: May 30, 2005, 08:02:37 PM »
Quote from: Jeff_M
Yes, I believe so. But don't be afraid to give it a try and ask lots of questions. There are plenty of folks here that can help you in that direction, too.

Michael, your code returns nothing if the "X" is clicked to close Acad2002 :?

Thanks Jeff, I did some VBA stuff, but mostly in Excel and in Acad only when i needed to get a link to Excel. Is there a  VBA command that would do the same as Vbarun in lisp, like starting a lispfile from VBA?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
reactor triggered when Autocad is exiting
« Reply #15 on: May 31, 2005, 07:06:35 AM »
Quote from: Jeff_M
Michael, your code returns nothing if the "X" is clicked to close Acad2002 :?

Thanks for confirming Jeff.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst