Author Topic: (challenge) Save editing time to a log file  (Read 10271 times)

0 Members and 1 Guest are viewing this topic.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
(challenge) Save editing time to a log file
« on: September 20, 2004, 04:42:59 PM »
To keep better track of what is being worked on for how long (mainly because I forget to fill my timesheet out until the day it needs to be turned in.)

Code: [Select]
*Open drawing sets start time
*Closing drawing ends timer
*Log file is edited to show the drawing name, date opened, time opened, time closed, total edited time per drawing, total edited time of all drawings
*Log file pertains to all drawings within the same folder, i.e. creates a different log file for drawings in a different folder.


Hope I'm not overstepping my boundries by issuing a challenge that I have no idea on how to complete...I guess this is more of a request, then.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(challenge) Save editing time to a log file
« Reply #1 on: September 20, 2004, 06:26:21 PM »
This would really be a VBA reactor type program. Probably more work than a challenge would be suitable for.
I'll look at what I have and see if I can find something.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

JohnK

  • Administrator
  • Seagull
  • Posts: 10651
(challenge) Save editing time to a log file
« Reply #2 on: September 20, 2004, 08:41:04 PM »
I think you could do that with VL.

Place code in a "comon tools.lsp" or your "Acad.lsp" file for the startup drawing part.

Create a reactor event for the command close or the doc close event and then your off and running.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

danny

  • Guest
(challenge) Save editing time to a log file
« Reply #3 on: September 20, 2004, 10:33:11 PM »
I've read an article, "Step Savers in AutoCAD 2005" by Lynn Allen, where her step saver # 10 states:
A new Express Tool called EditTime lets you track your drawing time to the second. You can turn the timer on and off and even specify a timeout period.  If there's no activity for that length of time, AutoCAD turns the timer off automatically.  Time information is stored with the drawing file, and you can access it via Visual LISP.

I have no idea how it works, but it would be a great management tool to incorporate in the earlier versions of CAD.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(challenge) Save editing time to a log file
« Reply #4 on: September 20, 2004, 11:22:33 PM »
Well now that you mention it, there is the drawing variable tdindwg
The return value is <days>.<fraction of days>

just do the math and it should give you the total editing time in a drawing.

There is also a diesel setting you can use:
Code: [Select]

$(edtime , $(getvar, tdindwg), dd:hh:mm:ss)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

SMadsen

  • Guest
Re: (challenge) Save editing time to a log file
« Reply #5 on: September 21, 2004, 05:25:30 AM »
Quote from: Dommy2Hotty
I guess this is more of a request, then.
Right.

The biggest problem with loggers like that - as well as the time records saved by the drawing - is non-billable time. What do you do when you go to lunch and leave the drawing open? Or get involved in projects that are billable elsewhere while having the drawing open? Or having a drawing open for design center purposes (copy/paste) without actually working on the drawing?

Sometimes I've been called out in haste to meetings that dragged out so long that getting back to the office wasn't an option. Leaving drawings open overnight seriously adds to billable time.

I've found that the human computer is the best time tracker there is. Just 2 euro cents.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
(challenge) Save editing time to a log file
« Reply #6 on: September 21, 2004, 09:59:59 AM »
Here is the previous thread on that subject.
http://theswamp.org/phpBB2/viewtopic.php?t=2238&highlight=timesheet

The software  use stops crediting time to a project is the keyboard and/or mouse is inactive for 3 min.
This timer is adjustable. If you take a call or do some work away from the computer
there is an icon to start a stop watch for that task.
If you are billing by the hour or keeping track of employees, this software will do it.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

sinc

  • Guest
(challenge) Save editing time to a log file
« Reply #7 on: February 16, 2005, 01:37:03 PM »
Quote from: Dommy2Hotty
To keep better track of what is being worked on for how long (mainly because I forget to fill my timesheet out until the day it needs to be turned in.)

I keep running into a similar problem.  But I don't really care too much about having a timer, I just need to remember what all I've been working on.

So I added the following to my acaddoc.lsp:

Code: [Select]
(defun timedate (/ cdate ctime ampm stime)
  (setq cdate (rtos (fix (getvar 'cdate)) 2 0)
ctime (rtos (rem (getvar 'cdate) 1) 2 6)
ampm  (if (<= (atof (substr ctime 3 2)) 12)
"AM"
"PM"
     )
stime (strcat
(substr cdate 1 4)
"-"
(substr cdate 5 2)
"-"
(substr cdate 7 2)
" "
(substr ctime 3 2)
":"
(substr ctime 5 2)
":"
(substr ctime 7 2)
":"
ampm
     )
  )
)
(defun-q MYSTARTUP ()
(if (not (wcmatch (getvar 'DWGNAME) "Drawing1.dwg"))
  (progn
  (setq FILEDESC (open "C:/AutocadFiles.log" "a"))
  (write-line
    (strcat (timedate)
    " "
    (getvar 'DWGNAME)
    " "
    (getvar 'DWGPREFIX)
    )
    FILEDESC
  )
  (close FILEDESC)
  (setq FILEDESC nil)
  )
)
)
(setq S::STARTUP (append S::STARTUP MYSTARTUP))

Just a simple thing that writes the time, date, name, and path of each drawing as it's opened.  As you can see, as listed here the log file is "C:AutocadFiles.log".  The check for "Drawing1.dwg" keeps it from logging "Drawing1" every time ACAD first starts up (I really wish Autodesk would fix that, and not create a "Drawing1" before running the startup dialog).

Is there a time limit on responses to challenges?  :)

ImaJayhawk

  • Guest
(challenge) Save editing time to a log file
« Reply #8 on: February 16, 2005, 05:55:17 PM »
I use Autocad Today to find out what drawings I've been working on....
Only use I've found for it. :?


-ImaJayhawk

sinc

  • Guest
(challenge) Save editing time to a log file
« Reply #9 on: February 16, 2005, 07:02:04 PM »
I completely forgot that thing existed.  I turned it off a long time ago, because it was annoying.  I just did a brief look, and couldn't even figure out how to get to it again.  I found one mention of it in the help, but nothing on how to get to it.  Since I don't really need or want it, I guess it's going to stay lost...  :lol:

ImaJayhawk

  • Guest
(challenge) Save editing time to a log file
« Reply #10 on: February 17, 2005, 10:31:39 AM »
I've got it turned off as well.  I just type today in the command line when I want to see what I've been working on.  
 :)

-ImaJayhawk

Big G

  • Bull Frog
  • Posts: 415
(challenge) Save editing time to a log file
« Reply #11 on: February 17, 2005, 10:52:40 AM »
Quote from: ImaJayhawk
I use Autocad Today to find out what drawings I've been working on....
Only use I've found for it. :?


-ImaJayhawk


heh that IS the only use for it!!
I thought i seen the light at the end of the tunnel. But it was just someone with a torch bringing me more work.
"You have to accept that somedays youre the pigeon and  somedays youre the statue"

nivuahc

  • Guest
(challenge) Save editing time to a log file
« Reply #12 on: February 17, 2005, 11:15:07 AM »
I feel silly even posting this but this is what I use in my MENU_NAME.mnl file to help us fill out our timesheets:

Code: [Select]
(defun cadlog (/ user_name job_no dwg_no open_time log_file)
  (setq user_name    (getvar "loginname")
job_no       (getvar "dwgprefix")
dwg_no       (getvar "dwgname")
open_time    (getvar "cdate")
log_file     (open (strcat "z:\\" user_name "_cadlog.txt") "a"))
(write-line (strcat (thedate open_time "-") " at " (thetime open_time nil) " " job_no dwg_no) log_file)
(close log_file)
)

   
I have the following two functions, thedate and thetime that I use a lot

Code: [Select]
(defun thedate (date1 sep1 /)
;;return the date as a string formatted like 03-06-2000
;;date1 = the date as returned by (getvar "cdate")
;;sep1  = the separator to be used (- of /)
(setq date1 (rtos date1 2 8))
(strcat (substr date1 5 2)
sep1
(substr date1 7 2)
sep1
(substr date1 1 4)
)
) ;_ end defun thedate


and

Code: [Select]
(defun thetime (date1 dec1 /)
;;return the time as a string formatted like 14:23:55 or 14:23:55.35
;;date1 = the date as returned by (getvar "cdate")
;;dec1  = if t, include decimals of a second, else hh:mm:ss.
(setq date1 (rtos date1 2 8))
(if dec1
(strcat (substr date1 10 2)
":"
(substr date1 12 2)
":"
(substr date1 14 2)
"."
(substr date1 16 2)
)
(strcat (substr date1 10 2)
":"
(substr date1 12 2)
":"
(substr date1 14 2)
)
) ;_ end if
) ;_ end defun thetime


What I end up with is something that looks like this, stored in a text file on each users Z drive called username_cadlog.txt

Code: [Select]
02-08-2005 at 08:09:57 P:\04068 ASU Student Center\dwgs\E204.dwg
02-08-2005 at 08:11:56 P:\04068 ASU Student Center\dwgs\E301A.dwg
02-08-2005 at 08:22:19 P:\04068 ASU Student Center\dwgs\E301B.dwg
02-08-2005 at 08:34:30 P:\04068 ASU Student Center\dwgs\E302A.dwg
02-08-2005 at 08:35:51 P:\04068 ASU Student Center\dwgs\E303A.dwg
...


The only drawback is that it doesn't tell you how long you actually worked on each drawing but, I don't really care about that. What I was concerned about was, 2 weeks after the fact, my memory (as well as everyone elses) needed a little jogging regarding what projects you were working on.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: (challenge) Save editing time to a log file
« Reply #13 on: October 11, 2005, 04:04:40 PM »
Quote from: Dommy2Hotty
To keep better track of what is being worked on for how long (mainly because I forget to fill my timesheet out until the day it needs to be turned in.)
I keep running into a similar problem.  But I don't really care too much about having a timer, I just need to remember what all I've been working on.

So I added the following to my acaddoc.lsp:

Code: [Select]
(defun timedate (/ cdate ctime ampm stime)
  (setq cdate (rtos (fix (getvar 'cdate)) 2 0)
ctime (rtos (rem (getvar 'cdate) 1) 2 6)
ampm  (if (<= (atof (substr ctime 3 2)) 12)
"AM"
"PM"
     )
stime (strcat
(substr cdate 1 4)
"-"
(substr cdate 5 2)
"-"
(substr cdate 7 2)
" "
(substr ctime 3 2)
":"
(substr ctime 5 2)
":"
(substr ctime 7 2)
":"
ampm
     )
  )
)
(defun-q MYSTARTUP ()
(if (not (wcmatch (getvar 'DWGNAME) "Drawing1.dwg"))
  (progn
  (setq FILEDESC (open "C:/AutocadFiles.log" "a"))
  (write-line
    (strcat (timedate)
    " "
    (getvar 'DWGNAME)
    " "
    (getvar 'DWGPREFIX)
    )
    FILEDESC
  )
  (close FILEDESC)
  (setq FILEDESC nil)
  )
)
)
(setq S::STARTUP (append S::STARTUP MYSTARTUP))
Just a simple thing that writes the time, date, name, and path of each drawing as it's opened.  As you can see, as listed here the log file is "C:AutocadFiles.log".  The check for "Drawing1.dwg" keeps it from logging "Drawing1" every time ACAD first starts up (I really wish Autodesk would fix that, and not create a "Drawing1" before running the startup dialog).

Is there a time limit on responses to challenges?  :)

This has worked for me with no problems.  I had a co-worker add this to her acad2004doc.lsp file and it gives her this error:
Code: [Select]
AutoCAD Express Tools Copyright © 2002-2003 Autodesk, Inc.
; error: Invalid attempt to access a compiled function definition.  You may
want to define it using defun-q: #<SUBR @05d2f9d8 S::STARTUP>

I added it to hers the same way I added it to mine:
Command: (startapp "notepad" (findfile "acad2004doc.lsp"))
But her's throws the error.  Any ideas?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: (challenge) Save editing time to a log file
« Reply #14 on: October 11, 2005, 04:14:44 PM »
On 'her' machine there must be a (defun S::STARTUP ( ) ... ) being executed before your (setq S::STARTUP (append S::STARTUP yada) stament. Check if she has an acad.lsp / acad.mnl etc. defining S::STARTUP before you get at it.

You could always add this --

Code: [Select]
(cond
    ;;  assuming the MYSTARTUP function is defined properly ...
    (   (null S::STARTUP) 
        (setq S::STARTUP MYSTARTUP)
    )
    (   (listp S::STARTUP)
        (setq S::STARTUP (append S::STARTUP MYSTARTUP))
    )
    (   (alert
            (strcat
                "Error:\n\n"
                "S::STARTUP function defined by defun, not defun-q."
            )   
        )
    )   
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: (challenge) Save editing time to a log file
« Reply #15 on: October 11, 2005, 04:38:37 PM »
Okay, I assume that I placed your cond in the right spot ( in place of the appending part ).  When a drawing is opened I receive the error that S::STARTUP function defined by defun, not defun-q.  Does that help diagnose the problem?

Code: [Select]
;;;OPEN DRAWING LOGFILE SECTION**********************

 

(defun timedate (/ cdate ctime ampm stime)
 (setq cdate (rtos (fix (getvar 'cdate)) 2 0)
          ctime (rtos (rem (getvar 'cdate) 1) 2 6)
          ampm  (if (<= (atof (substr ctime 3 2)) 12)
                   "AM"
                   "PM"
               )
          stime (strcat
                   (substr cdate 1 4)
                   "-"
                   (substr cdate 5 2)
                   "-"
                   (substr cdate 7 2)
                   " "
                   (substr ctime 3 2)
                   ":"
                   (substr ctime 5 2)
                   ":"
                   (substr ctime 7 2)
                   ":"
                   ampm
               )
 )
)

(defun-q MYSTARTUP ()
          (if (not (wcmatch (getvar 'DWGNAME) "Drawing1.dwg"))
            (progn
            (setq FILEDESC (open "C:\Opened_Files.log" "a"))
            (write-line
              (strcat (timedate)
                       " "
                       (getvar 'DWGPREFIX)
                       (getvar 'DWGNAME)
              )
              FILEDESC
            )
            (close FILEDESC)
            (setq FILEDESC nil)
            )
          )
)

(cond
    ;;  assuming the MYSTARTUP function is defined properly ...
    (   (null S::STARTUP) 
        (setq S::STARTUP MYSTARTUP)
    )
    (   (listp S::STARTUP)
        (setq S::STARTUP (append S::STARTUP MYSTARTUP))
    )
    (   (alert
            (strcat
                "Error:\n\n"
                "S::STARTUP function defined by defun, not defun-q."
            )   
        )
    )   
)


;;;;END OPEN DRAWING LOGFILE SECTION**********************

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: (challenge) Save editing time to a log file
« Reply #16 on: October 11, 2005, 04:42:29 PM »
Quote from: Dommy2Hotty
Okay, I assume that I placed your cond in the right spot ( in place of the appending part ).  When a drawing is opened I receive the error that S::STARTUP function defined by defun, not defun-q.  Does that help diagnose the problem?

Yep.

I'd search her machine for the string "s::startup" (case insensitive) and find all the locations where said statement exists. From there you need to consolidate / incorporate / distil. Notwithstanding, is her machine breaking any company standardization by having its own startup yada?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: (challenge) Save editing time to a log file
« Reply #17 on: October 11, 2005, 04:52:22 PM »
I'd search her machine for the string "s::startup" (case insensitive) and find all the locations where said statement exists. From there you need to consolidate / incorporate / distil. Notwithstanding, is her machine breaking any company standardization by having its own startup yada?

Thank you very much.  Is there an easy (prolly not) way to go about finding all the files that it can be in?  And no company standardization problems...her and I take care of all that, so whatever she's got going on with her computer is fine.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: (challenge) Save editing time to a log file
« Reply #18 on: October 11, 2005, 05:14:53 PM »
This at DOS:

Code: [Select]
findstr /i /s /m /c:"defun s::startup" c:\cad\*.lsp >> c:\HasStartupInIt.txt
findstr /i /s /m /c:"defun s::startup" c:\cad\*.mnl >> c:\HasStartupInIt.txt

Would put a listing of all lsp and mnl files that contain the phrase "defun s::startup" into the file c:\HasStartupInIt.txt. Like:

c:\cad\Acad2002\Sample\VisualLISP\External\blackboard.lsp
c:\cad\Acad2004\Sample\VisualLISP\External\blackboard.lsp
c:\cad\Acad2004\Support\sample-profile-util.lsp
c:\cad\Acad2004\Support\sample-profile-util.lsp


This of course, assuming the directory c:\cad were legit.

If you use /n instead of /m it will list the actual line numbers, like so --

c:\cad\Acad2002\Sample\VisualLISP\External\blackboard.lsp:181: (defun s::startup ()
c:\cad\Acad2004\Sample\VisualLISP\External\blackboard.lsp:181: (defun s::startup ()
c:\cad\Acad2004\Support\sample-profile-util.lsp:59:;;; (defun s::startup ()
c:\cad\Acad2004\Support\sample-profile-util.lsp:72:;;; (defun s::startup ()
« Last Edit: October 11, 2005, 05:20:40 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: (challenge) Save editing time to a log file
« Reply #19 on: October 11, 2005, 05:21:20 PM »
I see...thank you...let the search begin!

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: (challenge) Save editing time to a log file
« Reply #20 on: October 11, 2005, 05:24:44 PM »
Just be careful when using DOS redirection, i.e. this part:

>> c:\HasStartupInIt.txt

Two greater than signs (>>) appends new data to and existing data in the file c:\HasStartupInIt.txt. One greater than sign (>) will overwrite any existing data.

And there's no warning, it just obeys.

As it should.

:)

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

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: (challenge) Save editing time to a log file
« Reply #21 on: October 11, 2005, 05:27:13 PM »
And there's no warning, it just obeys.

As it should.

:)



 :-D

sinc

  • Guest
Re: (challenge) Save editing time to a log file
« Reply #22 on: October 31, 2005, 11:12:00 AM »
This has worked for me with no problems.  I had a co-worker add this to her acad2004doc.lsp file and it gives her this error:
Code: [Select]
AutoCAD Express Tools Copyright © 2002-2003 Autodesk, Inc.
; error: Invalid attempt to access a compiled function definition.  You may
want to define it using defun-q: #<SUBR @05d2f9d8 S::STARTUP>

I added it to hers the same way I added it to mine:
Command: (startapp "notepad" (findfile "acad2004doc.lsp"))
But her's throws the error.  Any ideas?
I don't think you should really be adding this to the "acad2004doc.lsp".  Technically, it should be placed in the "acaddoc.lsp" file.  In general, you shouldn't need or want to edit the acad2004doc.lsp.

This probably won't fix your problem, which is more likely caused by what MP suggests.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: (challenge) Save editing time to a log file
« Reply #23 on: October 31, 2005, 11:15:42 AM »
Just an update:

The problem was caused by FYPONCAD.  It created ACAD.LSP with one line: (Load FyponCad) <~basically
So I deleted that file and all is well.

Amsterdammed

  • Guest
Re: (challenge) Save editing time to a log file
« Reply #24 on: November 01, 2005, 07:19:05 AM »
Dommy,
I had the same Problem a while ago and Juerg Menzi wrote some great solution which works with a timeout function, so only when you WORK it will count the time.

Code: [Select]
;== AcadDoc.lsp ==============================================================
; Sets Command Reactors to collect the command time.
; Sets a DocManager Reactor to release the Reactor objects at the end
; of an AutoCAD session.
; Copyright:
;   ©2005 MENZI ENGINEERING GmbH, Switzerland
; Notes:
;   - None
; - Initialize ActiveX support
(vl-load-com)
;
; - Initialize session variables
;
(setq Me:DwgNme ""   ;empty drawing name
      Me:CmdTim 0   ;command time
      Me:CmdTmp 0   ;temporary command time
      Me:CmdCnt 0   ;command count
      Me:TimOut 180   ;command timeout
)
;
; - Reactors ------------------------------------------------------------------
;
; - If not set, initialize DocManager-Reactor
(or Me:ReaDma
 (setq Me:ReaDma (VLR-DocManager-Reactor
                  nil
                 '(
                   (:VLR-documentToBeDestroyed . MeDocToBeDestroyedCallbacks)
                  )
                 )
 )
)
; - If not set, initialize DWG-Reactor
(or Me:ReaDwg
 (setq Me:ReaDwg (VLR-DWG-Reactor
                  nil
                 '(
                   (:VLR-SaveComplete . MeDwgSaveCompleteCallbacks)
                  )
                 )
 )
)
; - If not set, initialize Command-Reactor
(or Me:ReaCom
 (setq Me:ReaCom (VLR-Command-Reactor
                  nil
                 '(
                   (:VLR-commandWillStart . MeCommandWillStartCallbacks)
                   (:VLR-commandEnded . MeCommandEndedCallbacks)
                   (:VLR-commandCancelled . MeCommandCancelledCallbacks)
                  )
                 )
 )
)
;
; - Notifications -------------------------------------------------------------
;
; - MeDwgSaveComplete notifications
(defun MeDwgSaveCompleteCallbacks (Rea Arg)
 (MeDoDwgSaveCompleteStuff Arg)
 (princ)
)
; - CommandWillStart notifications
(defun MeCommandWillStartCallbacks (Rea Arg)
 (MeDoCmdWillStartStuff Arg)
 (princ)
)
; - CommandEnded notifications
(defun MeCommandEndedCallbacks (Rea Arg)
 (MeDoCmdEndedStuff Arg)
 (princ)
)
; - CommandCancelled notifications
(defun MeCommandCancelledCallbacks (Rea Arg)
 (MeDoCmdCancelledStuff Arg)
 (princ)
)
; - DocToBeDestroyed notifications
(defun MeDocToBeDestroyedCallbacks (Rea Arg)
 (MeWriteToLog)
 (MeDoCloseStuff)
 (princ)
)
;
; - Subs ----------------------------------------------------------------------
;
; - DWG save complete function
(defun MeDoDwgSaveCompleteStuff (Arg)
 (setq Me:DwgNme (cadr Arg))
 (princ)
)
; - Command will start function
(defun MeDoCmdWillStartStuff (Arg)
 (setq Me:CmdTmp (getvar "MILLISECS")
       Me:CmdCnt (1+ Me:CmdCnt)
 )
 (princ)
)
; - Command ended function
(defun MeDoCmdEndedStuff (Arg / TmpVal)
 (setq TmpVal (- (getvar "MILLISECS") Me:CmdTmp)
       Me:CmdTim (if (> TmpVal (* Me:TimOut 1000)) ;User is sleeping
                  Me:CmdTim
                  (+ TmpVal Me:CmdTim)
                 )
 )
 (princ)
)
; - Command cancelled function
(defun MeDoCmdCancelledStuff (Arg / TmpVal)
 (setq TmpVal (- (getvar "MILLISECS") Me:CmdTmp)
       Me:CmdTim (if (> TmpVal (* Me:TimOut 1000)) ;User was sleeping
                  Me:CmdTim
                  (+ TmpVal Me:CmdTim)
                 )
 )
 (princ)
)
;
; - Write to log function
(defun MeWriteToLog ()
 (alert (strcat
         "Drawing name:\t\t" Me:DwgNme
         "\nTotal command time:\t" (MeCalcTime Me:CmdTim)
         "\nTotal commands called:\t" (itoa Me:CmdCnt)
        )
 )
 (princ)
)
; - 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)
)
; - Calculate time from msecs
(defun MeCalcTime (Val / TimHrs TimMin TimSec TmpVal)
 (setq TmpVal (fix (/ Val 1000.0))
       TimSec (rem TmpVal 60)
       TmpVal (/ (- TmpVal TimSec) 60)
       TimMin (rem TmpVal 60)
       TimHrs (/ (- TmpVal TimMin) 60)
 )
 (strcat (itoa TimHrs) "h " (itoa TimMin) "m " (itoa TimSec) "s")     
)

(princ)
; == End AcadDoc.lsp ==========================================================


I hope this helps you,

Bernd