Jump to content

Recommended Posts

Posted

This should do it. If you want the date to be in another format, just change that line.

;;Author: Lee-Mac
;;Date: 01/27/10
;;Modified By:Commandobill
;;Date 04/21/15
;;Reason for change: Updated to make text file be in a static position instead of dynamic.
(defun TimeReac nil
(vl-load-com)
(if (not (vl-position "TIMEREACT"
(mapcar (function strcase)
(mapcar (function vlr-data)
(mapcar (function cadr)
(vlr-reactors :vlr-command-reactor))))))
(progn
(vlr-command-reactor "TIMEREACT"
(list
(cons :vlr-commandWillStart 'GetTime_C)
(cons :vlr-commandEnded 'GetTime_O)))
     
(princ "\n<< Reactor Initiated >>"))
   
(princ "\n<< Reactor Already Running >>"))
 
(princ))

(TimeReac)


(defun GetTime_O (Reactor Args)
(if (eq "OPEN" (strcase (car Args)))
(GetTime))
(princ))


(defun GetTime_C (Reactor Args)
(if (eq "CLOSE" (strcase (car Args)))
(GetTime))
(princ))


(defun GetTime (/ toDate *error* ofile)
 
(defun toDate (var format)
(menucmd (strcat "m=$(edtime,$(getvar," var ")," format ")")))
 
(defun *error* (msg)
(and ofile (close file))
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(princ))
 
(if (setq ofile (open (strcat "C:\\Users\\Acad2015\\TimeLog\\Logfile" (toDate "DATE" "YYYYMODD") ".txt") "a"));;Location of change
(progn
(if (eq "CLOSE" (strcase (car Args)))
(write-line "ACTION: CLOSED" ofile)
(write-line "ACTION: OPENED" ofile))
(write-line (strcat "DATE: " (toDate "DATE" "MO.DD.YY ** HH.MM.SS")) ofile)
(write-line (strcat "DRAWING: " (getvar 'DWGPREFIX) (getvar 'DWGNAME) "\n") ofile)
     
     
(setq ofile (close ofile))))
 
(princ))



(defun c:TimeOFF (/ Reac)
(vl-load-com)
(if (and (setq Reac
(car
(vl-remove-if-not
(function
(lambda (x)
(eq "TIMEREACT" (strcase (vlr-data x)))))
(mapcar (function cadr)
(vlr-reactors :vlr-command-reactor)))))
(vlr-added-p Reac))
(progn
(vlr-remove Reac)
(princ "\n<< Reactor Deactivated >>"))
   
(princ "\n** Reactor Not Running **"))
 
(princ))

  • Replies 31
  • Created
  • Last Reply

Top Posters In This Topic

  • JoeyG_77

    15

  • Commandobill

    10

  • BIGAL

    3

  • tzframpton

    2

Posted

you my friend are awesome !!! ... This is exactly what I wanted ... it seems to hiccup a little by not logging the action but its all that i wanted =) Thanks Bill

Posted
you my friend are awesome !!! ... This is exactly what I wanted ... it seems to hiccup a little by not logging the action but its all that i wanted =) Thanks Bill

 

You're welcome. I hope Lee doesn't mind me messing around with his code too much, I'm sure he has something more advanced out there.

Posted

I don't think he would ! ... This was specific and works great .. I just need it to log just like that =) Now if it would stop being temperamental and just log it every time it would be great but this is autocad so nothing can be simple !!! ... Thanks again :D

Posted

Ok bill .... I found another one that is even better because this allows you to start n stop it manually and have icons to match the start n stop .. The only thing is being able to have them all go into one file ... It over writes the content when u start and stop it in different drawings ... So I need to have all in one file and the date to automatically populate so I have a running list of days in the folder ... I think you will like this one for sure . Or anyone else that can help I would love the help

Joey g

 ;;;*This is a Drawing Log Routine that logs the date, time, &
;;;*Drawing Name of each Drawing Session. It writes a report
;;;*to an ASCII Text file (Log.Txt).
;;;*If you wish you can load Login.Lsp from your Acad.Lsp file,
;;;*and edit the Acad.mnu to call the Logout.Lsp routine before
;;;*Exiting, Quiting or starting a new drawing.
;;;*============================================================
(defun C:LOGIN ( / a c d file fp)
  (if (not file)
               (open "C:\\Users\\Acad2015\\TimeLog\\Logfile.txt" "w")
  );if
  (setq a (TODAY)
     TIME1 (TIME)
     c (getvar "DWGNAME")
     d (strcat "Drawing Started   " a "  -  " TIME1 "  -  " c)
  );setq
  (if (/= c "Drawing.dwg")
     (progn  
        (setq file (findfile "C:\\Users\\Acad2015\\TimeLog\\Logfile.txt")
           fp (open file "a")
        );setq
        (princ d fp)
        (princ "\n" fp)
        (close fp)
        (princ (strcat "\nLogged in at : " TIME1))
     );progn
  );if
  (princ)
);defun
;;;*-------------------------------------------------
(defun C:LOGOUT ( / a c d file fp)
  (setq a (TODAY)
     TIME2 (TIME)
     c (getvar "DWGNAME")
     d (strcat "Drawing Exit    " a "  -  " TIME2 "  -  " c)
  );setq
  (if (/= c "Drawing.dwg")
     (progn  
        (setq file (findfile "C:\\Users\\Acad2015\\TimeLog\\Logfile.txt")
           fp (open file "a")
        );setq
        (princ d fp)
        (princ "\n" fp)
        (close fp)
        (princ (strcat "\nLogged out at : " TIME2))
        (etime)
     );progn
  );if
  (princ)
);defun
;;;*-------------------------------------------------
(defun ETIME ( / hr1 m1 s1 tot1 hr2 m2 s2 tot2 total ht mt file fp)
  (setq hr1 (* 60 (* 60 (atof (substr time1 1 2))))
     m1 (* 60 (atof (substr time1 4 2)))
     s1 (atof (substr time1 7 2))
     tot1 (+ hr1 m1 s1)
     hr2 (* 3600 (atof (substr time2 1 2)))
     m2 (* 60 (atof (substr time2 4 2)))
     s2 (atof (substr time2 7 2))
     tot2 (+ hr2 m2 s2)
     total (- tot2 tot1)
     hr1 (/ total 3600)
     ht (fix hr1)
     hr1 (- hr1 ht)
     mt (* hr1 60)
     ht (rtos ht)
     mt (rtos mt) 
  );setq
  (setq d (strcat "Editing Time This Session :  " ht " Hours and " mt " minutes"))
  (setq file (findfile "C:\\Users\\Acad2015\\TimeLog\\Logfile.txt")
     fp (open file "a")
  );setq
  (princ d fp)
  (princ "\n" fp)
  (princ "==============================================================" fp )
  (princ "\n" fp)
  (close fp)
  (princ)
);defun
;;;*-------------------------------------------
;;;*Calculates the Current Date
(defun TODAY ( / d yr mo day)
    (setq d (rtos (getvar "CDATE") 2 6)
         yr (substr d 3 2)
         mo (substr d 5 2)
        day (substr d 7 2)
    );setq
    (strcat mo "/" day "/" yr)
);defun
;;;*-------------------------------------------
;;;*Calculates the Current Time
(defun TIME ( / d hr m s)
    (setq d (rtos (getvar "CDATE") 2 6)
         hr (substr d 10 2)
          m (substr d 12 2)
          s (substr d 14 2)
    );setq
    (strcat hr ":" m ":" s)
);defun
(princ)

Posted

Do you have a lisp routine that tracks the time spent to go to the bathroom, get a cup of coffee, have a drink of water, stop to chat with a coworker, get summoned to your boss's office for a quick question that somehow turns into a forty five minute discussion, read or write email, stop for lunch, go to the copier, surf the Internet, etc., etc., etc.? Just curious.

Posted

I don't .... But can you help with the code ?

Posted

Go back look at my post I think its what you want the one file with multiple days in it.

 

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&& REPORT ON USER'S COMMANDS USAGE &&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
START TIME of report entry .... 2015.Apr.07 11:17:23
END TIME of report entry ...... 2015.Apr.07 11:27:21
Total period ............................... 00:09:58
FILENAME: 2006139-rev1.dwg
DIRECTORY: P:\2014 Projects\2014139\Design\
DATE CREATED: 2010.Aug.24 15:44:54
LAST SAVE: 2015.Apr.07 11:27:19
TOTAL EDITING TIME: 255:17:34
COMPUTER NAME: ITYYYY
LOGGED USER: AhXXXX
AUTOCAD VERSION: 19.0s (LMS Tech)
+=======================================================================+
| command name | num. calls | in % || time | in % |
+=======================================================================+
| LAYOUT_CONTROL ............ 13 = 46% || 00:00:12 = 8% |
| ERASE ..................... 3 = 10% || 00:00:00 = 0% |
| PLOT ...................... 3 = 10% || 00:02:01 = 76% |
| LIST ...................... 2 = 7% || 00:00:00 = 0% |
| CLOSE ..................... 1 = 3% || 00:00:03 = 2% |
| PSPACE .................... 1 = 3% || 00:00:00 = 0% |
| QSAVE ..................... 1 = 3% || 00:00:01 = 0% |
| MSPACE .................... 1 = 3% || 00:00:00 = 0% |
| ROTATE .................... 1 = 3% || 00:00:06 = 4% |
| LINE ...................... 1 = 3% || 00:00:06 = 4% |
| DIST ...................... 1 = 3% || 00:00:05 = 3% |
| || |
| TOTAL 28 || 00:02:37 |
+=======================================================================+
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&& END OF REPORT &&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

Posted

Al .. Thats alot of info this is what the last code outputs ... I just need a stop and start but need it to write all into one file for every time i use the commands and everyday when i start the lisp to name the text file with today's date to it ... this is what is generated from the lisp

 

Drawing Started 04/23/15 - 15:41:17 - Churchill_FamilyRoom_Rev0.dwg

Drawing Exit 04/23/15 - 15:41:19 - Churchill_FamilyRoom_Rev0.dwg

Editing Time This Session : 0.0000 Hours and 0.0333 minutes

==============================================================

Posted

BIGAL, I did a search on here for that, and all I can find is multiple posts of you saying to do a search for it. lol

Posted

I need one more thing ... come on PLEASE PLEASE !!! :notworthy: I had this code with bill from my other lisp .. but when I run it I get an error that says its not defined and I have no idea how to define it so it will name the file as I want. Take a look and help me out I would appreciate it.

 

;;;*This is a Drawing Log Routine that logs the date, time, &
;;;*Drawing Name of each Drawing Session. It writes a report
;;;*to an ASCII Text file (Log.Txt).
;;;*If you wish you can load Login.Lsp from your Acad.Lsp file,
;;;*and edit the Acad.mnu to call the Logout.Lsp routine before
;;;*Exiting, Quiting or starting a new drawing.
;;;*============================================================
(defun C:LOGIN ( / a c d file fp)
(setq filedef (findfile "C:\\Users\\Acad2015\\TimeLog\\Logfile-" (toDate "DATE" "MODDYY") ".txt"))
  (if (not filedef)
(open ((strcat "C:\\Users\\Acad2015\\TimeLog\\Logfile-" (toDate "DATE" "MODDYY") ".txt") "a"))
  );if
  (setq a (TODAY)
     TIME1 (TIME)
     c (getvar "DWGNAME")
     d (strcat "Drawing Started   " a "  -  " TIME1 "  -  " c)
  );setq
  (if (/= c "Drawing.dwg")
     (progn  
        (setq file (findfile "C:\\Users\\Acad2015\\TimeLog\\Logfile-" (toDate "DATE" "MODDYY") ".txt")
           fp (open file "a")
        );setq
        (princ d fp)
        (princ "\n" fp)
        (close fp)
        (princ (strcat "\nLogged in at : " TIME1))
     );progn
  );if
  (princ)
);defun
;;;*-------------------------------------------------
(defun C:LOGOUT ( / a c d file fp)
  (setq a (TODAY)
     TIME2 (TIME)
     c (getvar "DWGNAME")
     d (strcat "Drawing Exit    " a "  -  " TIME2 "  -  " c)
  );setq
  (if (/= c "Drawing.dwg")
     (progn  
        (setq file (findfile "C:\\Users\\Acad2015\\TimeLog\\Logfile-" (todate "DATE" "MODDYY") ".txt")
           fp (open file "a")
        );setq
        (princ d fp)
        (princ "\n" fp)
        (close fp)
        (princ (strcat "\nLogged out at : " TIME2))
        (etime)
     );progn
  );if
  (princ)
);defun
;;;*-------------------------------------------------
(defun ETIME ( / hr1 m1 s1 tot1 hr2 m2 s2 tot2 total ht mt file fp)
  (setq hr1 (* 60 (* 60 (atof (substr time1 1 2))))
     m1 (* 60 (atof (substr time1 4 2)))
     s1 (atof (substr time1 7 2))
     tot1 (+ hr1 m1 s1)
     hr2 (* 3600 (atof (substr time2 1 2)))
     m2 (* 60 (atof (substr time2 4 2)))
     s2 (atof (substr time2 7 2))
     tot2 (+ hr2 m2 s2)
     total (- tot2 tot1)
     hr1 (/ total 3600)
     ht (fix hr1)
     hr1 (- hr1 ht)
     mt (* hr1 60)
     ht (rtos ht)
     mt (rtos mt) 
  );setq
  (setq d (strcat "Editing Time This Session :  " ht " Hours and " mt " minutes"))
  (setq file (findfile "C:\\Users\\Acad2015\\TimeLog\\Logfile-" (todate "DATE" "MODDYY") ".txt") 
     fp (open file "a")
  );setq
  (princ d fp)
  (princ "\n" fp)
  (princ "==============================================================" fp )
  (princ "\n" fp)
  (close fp)
  (princ)
);defun
;;;*-------------------------------------------
;;;*Calculates the Current Date
(defun TODAY ( / d yr mo day)
    (setq d (rtos (getvar "CDATE") 2 6)
         yr (substr d 3 2)
         mo (substr d 5 2)
        day (substr d 7 2)
    );setq
    (strcat mo "/" day "/" yr)
);defun
;;;*-------------------------------------------
;;;*Calculates the Current Time
(defun TIME ( / d hr m s)
    (setq d (rtos (getvar "CDATE") 2 6)
         hr (substr d 10 2)
          m (substr d 12 2)
          s (substr d 14 2)
    );setq
    (strcat hr ":" m ":" s)
);defun
(princ) 

Posted

Productivity analysis tool.lsp You can rem out some of the write-line to shorten the report.

 

;This lisp program counts the AutoCAD commands and time 
;;; FILENAME:    Productivity_Analisys_Tool.lsp 
;;; 
;;; CREATED BY:  Konstantin Gerasimov, kosio_gerasimov@abv.bg 
;;;              Technical University of Varna, Bulgaria 
;;; DATE:        22.Jan.2010
;;; VERSION:     v1.1
;;; 
;;; This lisp program counts the AutoCAD commands you have copleted and how much time you have spent on each command. 
;;; You cannot call it from the command prompt. You just need to add the program to the startup suite so that it is loaded in 
;;; every AutoCAD file you open. When you hit the close button a productivity report will be generated. It will be 
;;; stored in the directory of the correspondent dwg and will be named <your drawing name>_ProductivityReport.txt 
;;; These reports will be appended in the aforementioned file every time you hit the close button. 
;;; I recommend you after closing your file to open the productivity report and in the corresponding place to 
;;; write comments on what work you were doing. 
;;; You can also issue a productivity report by writing genProductivityReport in the command prompt. 
;;; 
;;; This program can be used by anybody for any purposewithout fee. However no warranty is granted. 
;;; If you just mention my name it will warmen my heart:) 
;;; Keep in mind that reactor might be tricky so hit the save button from time to time:) 
;;; 
;;; As a starting point I have copied some source code from here: http://www.cadtutor.net/forum/showthread.php?t=27191 
;;; here: http://autocad.xarch.at/code/olasov/econo3.lsp 
;;; and here: http://xarch.tu-graz.ac.at/autocad/stdlib/ 
;;; Special thanks to the authors of the aforementioned resourses for sharing their work with us:) 

;;; Initialization
(VL-LOAD-COM)

(SETQ start_date_pat	 (GETVAR "CDATE")
     start_time_pat	 (GETVAR "TDUSRTIMER")
     cmd_start_time_pat (GETVAR "TDUSRTIMER")
)


;;; Definition of the reactor which will listen for issued commands
(DEFUN CmdSpy ()
  (IF (NOT cmdspy:cmdreactor)
     (SETQ
 cmdspy:cmdreactor (VLR-COMMAND-REACTOR
		      nil
		      '((:VLR-COMMANDWILLSTART . startCmdTimer_pat) (:VLR-COMMANDENDED . CmdSpyReaction_pat))
		   )		; end VLR-COMMAND-REACTOR
     )					; end setq
  )					; end if
  (PRINC)
)					; end of CmdSpy

;;; Definition of auxilary function for the reactors
(DEFUN startCmdTimer_pat (reactor_object cmd_Name)
  (IF (= reactor_object cmdspy:cmdreactor)
     (SETQ cmd_start_time_pat (GETVAR "TDUSRTIMER"))
  )
)


;; Counts the command calls and record the time the command was active
(DEFUN CmdSpyReaction_pat (reactor_object cmd_Name / cLst)
  (IF (= reactor_object cmdspy:cmdreactor)
     (IF (NOT (SETQ cLst (ASSOC (CAR cmd_Name) cmdspy:list)))
 (SETQ
    cmdspy:list	(CONS (CONS (CAR cmd_Name) (LIST 1 (- (GETVAR "TDUSRTIMER") cmd_start_time_pat))) cmdspy:list)
 )
 (SETQ
    cmdspy:list	(SUBST
		   (CONS (CAR cmd_Name)
			 (LIST (1+ (CADR cLst)) (+ (CADDR cLst) (- (GETVAR "TDUSRTIMER") cmd_start_time_pat)))
		   )
		   cLst
		   cmdspy:list
		)
 )
     )					; end if
  )
  (PRINC)
)					; end of CmdSpyReaction_pat


;;; This function creates and writes the productivity report
(DEFUN c:genProductivityReport (/ insertIntroduction cTotalCmdsNumber cTotalCmdsTime reportname	fid textline
			num_cmd_percent	cmd_time_percent
		       )
  (PRINC "\nGenerating the productivity report. Please wait a few moments... ")
  (SETQ insertIntroduction nil)
  (IF cmdspy:list
     (PROGN
 (SETQ cmdspy:list	(VL-SORT cmdspy:list '(LAMBDA (a b) (> (CADR a) (CADR b))))
       cTotalCmdsNumber	(APPLY '+ (MAPCAR 'CADR cmdspy:list))
       cTotalCmdsTime	(APPLY '+ (MAPCAR 'CADDR cmdspy:list))
 )				; end setq
 (IF (= (GETVAR "DWGTITLED") 1)
    (PROGN
       ;(SETQ reportname (STRCAT (GETVAR "DWGPREFIX") (GETVAR "DWGNAME") "_Productivity_Report.txt"))


(SETQ reportname (STRCAT "P:/TEMP/" (getenv "username") "_" (GETVAR "DWGNAME") "_Productivity_Report.txt"))
    

(IF (NOT (OPEN reportname "r"))
	  (SETQ insertIntroduction T)
       )
       (IF (NULL (SETQ fid (OPEN reportname "a")))
	  (PRINC (STRCAT "\nCouldn't open " reportname " for writing!!!\n"))
	  (PROGN
	     (IF insertIntroduction
		(PROGN
		;(WRITE-LINE "   created meaning that you may copy the dwg file and you will still get the" fid )
		; (WRITE-LINE "   same create date." fid)
		; (WRITE-LINE "2) TOTAL EDITING TIME represents the total time the drawing was opened and " fid)
		; (WRITE-LINE "   loaded in AutoCAD and the internal timer was on (see time function)." fid)
		; (WRITE-LINE "3) Only AutoCAD's native commands that were completed (and no ESC button was" fid)
		; (WRITE-LINE "   pressed) and ended without errors are counted." fid)
		; (WRITE-LINE "4) The time spent on each command might not be the exact one (because of the" fid)
		; (WRITE-LINE "   use of reactors) but should be pretty close to the real one. Also the per-" fid)
		; (WRITE-LINE "   countage is calculated based on the total time spent in active commands, " fid)
		; (WRITE-LINE "   not on the total period of the report.\n\n\n\n" fid)
	        )
	     )
	     (WRITE-LINE "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" fid)
	     (WRITE-LINE "&&&&&&&&&&&&&&&&     REPORT ON USER'S COMMANDS USAGE     &&&&&&&&&&&&&&&&" fid)
	     (WRITE-LINE "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" fid)
	     (WRITE-LINE (STRCAT "START TIME of report entry .... " (parseDate start_date_pat)) fid)
	     (WRITE-LINE (STRCAT "END TIME of report entry ...... " (parseDate (GETVAR "CDATE"))) fid)
	     (WRITE-LINE (STRCAT "Total period ............................... "
				 (parseTime (- (GETVAR "TDUSRTIMER") start_time_pat))
			 )
			 fid
	     )
	     (WRITE-LINE (STRCAT "\nFILENAME:           " (GETVAR "DWGNAME")) fid)
	     (WRITE-LINE (STRCAT "DIRECTORY:          " (GETVAR "DWGPREFIX")) fid)
	     (WRITE-LINE (STRCAT "DATE CREATED:       " (STD-DATE->DATLST (GETVAR "TDCREATE"))) fid)
	     (WRITE-LINE (STRCAT "LAST SAVE:          " (STD-DATE->DATLST (GETVAR "TDUPDATE"))) fid)
	     (WRITE-LINE (STRCAT "TOTAL EDITING TIME: " (parseTime (GETVAR "TDINDWG"))) fid)
	     (WRITE-LINE (STRCAT "COMPUTER NAME:      "
				 (IF (GETENV "computername")
				    (GETENV "computername")
				    ""
				 )
			 )
			 fid
	     )
	     (WRITE-LINE (STRCAT "LOGGED USER:        "
				 (IF (GETENV "username")
				    (GETENV "username")
				    ""
				 )
			 )
			 fid
	     )
	     (WRITE-LINE (STRCAT "AUTOCAD VERSION:    "
				 (IF (GETVAR "ACADVER")
				    (GETVAR "ACADVER")
				    ""
				 )
			 )
			 fid
	     )
	     (WRITE-LINE "\n+=======================================================================+" fid)
	     (WRITE-LINE "|      command name    | num. calls |   in %  ||     time     |   in %  |" fid)
	     (WRITE-LINE "+=======================================================================+" fid)
	     (FOREACH i	cmdspy:list
		(SETQ textline (STRCAT "| " (CAR i) " "))
		(REPEAT (- 26 (STRLEN (CAR i))) (SETQ textline (STRCAT textline ".")))
		(SETQ textline (STRCAT textline " " (ITOA (CADR i))))
		(REPEAT (- 6 (STRLEN (ITOA (CADR i)))) (SETQ textline (STRCAT textline " ")))
		(SETQ num_cmd_percent (ITOA (FIX (/ (* (CADR i) 100) cTotalCmdsNumber))))
		(SETQ textline (STRCAT textline "=   " num_cmd_percent "%"))
		(REPEAT (- 5 (STRLEN num_cmd_percent)) (SETQ textline (STRCAT textline " ")))
		(SETQ textline (STRCAT textline "||   " (parseTime (CADDR i)) "   =   "))
		(SETQ cmd_time_percent (FIX (/ (* (CADDR i) 100) cTotalCmdsTime)))
		(SETQ textline (STRCAT textline
				       (ITOA cmd_time_percent)
				       (IF (< cmd_time_percent 10)
					  "%    |"
					  "%   |"
				       )
			       )
		)
		(WRITE-LINE textline fid)
	     )			; end foreach
	     (WRITE-LINE "|                                             ||                        |" fid)
	     (SETQ textline (STRCAT "| TOTAL                       " (ITOA cTotalCmdsNumber)))
	     (REPEAT (- 16 (STRLEN (ITOA cTotalCmdsNumber))) (SETQ textline (STRCAT textline " ")))
	     (SETQ textline (STRCAT textline "||   " (parseTime cTotalCmdsTime) "             |"))
	     (WRITE-LINE textline fid)
	     (WRITE-LINE "+=======================================================================+" fid)
	
	     (WRITE-LINE "\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" fid)
	     (WRITE-LINE "&&&&&&&&&&&&&&&&&             END OF REPORT             &&&&&&&&&&&&&&&&&" fid)
	     (WRITE-LINE "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n\n\n" fid)
	     (CLOSE fid)
	     ;; Reinitialization
	     (SETQ cmdspy:list	  nil
		   start_date_pat (GETVAR "CDATE")
		   start_time_pat (GETVAR "TDUSRTIMER")
	     )
	  )			; end of progn if null else
       )			; end of if NULL
    )				; end of progn if DWGTITLED
   ; (PRINC "\nThe drawing wasn't saved at all so no report will be formed.\n")
;un rem if required
 )				; end if DWGTITLED
     )					; end progn
     (PRINC "\nNo command history found!\n")
  )					; end if
  (PRINC)
)					; end of c:genProductivityReport


;;; Prepares the date and time in an appropriate printable format
;;; (for the CDATE)
(DEFUN parseDate (cdate / date_str year month day hour mins secs date_txt month_txt)
  (IF cdate
     (PROGN (SETQ date_str (RTOS cdate 2 6)
	   year	    (SUBSTR date_str 1 4)
	   month    (SUBSTR date_str 5 2)
	   day	    (SUBSTR date_str 7 2)
	   hour	    (SUBSTR date_str 10 2)
	   mins	    (SUBSTR date_str 12 2)
	   secs	    (SUBSTR date_str 14 2)
     )
     (SETQ month_txt (COND ((= month "01") "Jan")
			   ((= month "02") "Feb")
			   ((= month "03") "Mar")
			   ((= month "04") "Apr")
			   ((= month "05") "May")
			   ((= month "06") "Jun")
			   ((= month "07") "Jul")
			   ((= month "08") "Aug")
			   ((= month "08") "Sep")
			   ((= month "10") "Oct")
			   ((= month "11") "Nov")
			   ((= month "12") "Dec")
			   (T "___")
		     )
     )
     (SETQ date_txt (STRCAT year "." month_txt "." day "  " hour ":" mins ":" secs))
     )
     ""				; else return empty string
  )
)					; end of parseDate


;;; Prepares the time in an appropriate printable format
;;; (for the TDUSRTIMER)
(DEFUN parseTime (time / time_secs hrs mns secs time_txt)
  (IF time
     (PROGN (SETQ time_secs (* 86400.0 time)
	   hrs	     (FIX (/ time_secs 3600.0))
	   mns	     (FIX (/ (- time_secs (* hrs 3600.0)) 60.0))
	   secs	     (FIX (- time_secs (+ (* hrs 3600.0) (* mns 60.0))))
     )
     (SETQ time_txt (STRCAT (IF	(< hrs 10)
			       "0"
			       ""
			    )
			    (ITOA hrs)
			    ":"
		    )
     )
     (SETQ time_txt (STRCAT time_txt
			    (IF	(< mns 10)
			       "0"
			       ""
			    )
			    (ITOA mns)
			    ":"
		    )
     )
     (SETQ time_txt (STRCAT time_txt
			    (IF	(< secs 10)
			       "0"
			       ""
			    )
			    (ITOA secs)
		    )
     )
     )
     ""				; else return empty string
  )
)					; end of parseTime


;;; This function I have copied and have made minor modification in its output result. Here is its copyrights info: 
;;;$Id: STDTIME.LSP 0.5006 2000/12/31 10:59:00 rurban Rel $ -*-AutoLISP-*-
;;; Time-stamp: <2000-12-31 11:31:03 rurban>
;;; Copyright (c) 1994,1998,2000 by Reini Urban
;;; Available for free at http://xarch.tu-graz.ac.at/autocad/stdlib/ 
;;; 
;;; (for the TDCREATE TDUPDATE 
(DEFUN STD-DATE->DATLST	(date / time julian yr day mo hh ss mm month_txt day_txt time_txt date_printable)
  (SETQ time (* 86400.0 (- date (SETQ julian (FIX date)))))
  (SETQ julian (- julian 1721119))
  (SETQ yr (/ (1- (* 4 julian)) 146097))
  (SETQ julian (- (* julian 4) 1 (* 146097 yr)))
  (SETQ day (/ julian 4))
  (SETQ julian (/ (+ (* 4 day) 3) 1461))
  (SETQ day (- (+ (* 4 day) 3) (* 1461 julian)))
  (SETQ day (/ (+ day 4) 4))
  (SETQ mo (/ (- (* 5 day) 3) 153))
  (SETQ day (- (* 5 day) 3 (* 153 mo)))
  (SETQ day (/ (+ day 5) 5))
  (SETQ yr (+ (* 100 yr) julian))
  (IF (< mo 10)
     (SETQ mo (+ mo 3))
     (SETQ mo (- mo 9)
    yr (1+ yr)
     )
  )
  (SETQ hh (FIX (/ time 3600.0)))
  (SETQ time (- time (* hh 3600)))
  (SETQ mm (FIX (/ time 60.0)))
  (SETQ ss (- time (* mm 60)))
  ;; From here start my modification
;;;  (list yr mo day hh mm ss)
  (SETQ month_txt (COND ((= mo 1) "Jan")
		 ((= mo 2) "Feb")
		 ((= mo 3) "Mar")
		 ((= mo 4) "Apr")
		 ((= mo 5) "May")
		 ((= mo 6) "Jun")
		 ((= mo 7) "Jul")
		 ((= mo  "Aug")
		 ((= mo 9) "Sep")
		 ((= mo 10) "Oct")
		 ((= mo 11) "Nov")
		 ((= mo 12) "Dec")
		 (T "___")
	   )
  )
  (SETQ day_txt (STRCAT (IF (< day 10)
		    "0"
		    ""
		 )
		 (ITOA day)
	 )
  )
  (SETQ time_txt (STRCAT (IF (< (FIX hh) 10)
		     "0"
		     ""
		  )
		  (ITOA (FIX hh))
		  ":"
	  )
  )
  (SETQ time_txt (STRCAT time_txt
		  (IF (< (FIX mm) 10)
		     "0"
		     ""
		  )
		  (ITOA (FIX mm))
		  ":"
	  )
  )
  (SETQ time_txt (STRCAT time_txt
		  (IF (< (FIX ss) 10)
		     "0"
		     ""
		  )
		  (ITOA (FIX ss))
	  )
  )
  (SETQ date_printable (STRCAT (ITOA yr) "." month_txt "." day_txt "  " time_txt))
)


;;; Definition of the reactor which will start the productivity report generation when you are about to close the drawing
(DEFUN Create_Close_Reactor ()
  (IF (NOT close:reactor)
     (SETQ close:reactor (VLR-EDITOR-REACTOR nil '((:VLR-BEGINCLOSE . CloseReaction))))
  )					; end if
  (PRINC)
)					; end of Create_Close_Reactor

;;; Runs the report generator
(DEFUN CloseReaction (reactor_object Args)
  (IF (= reactor_object close:reactor)
     (c:genProductivityReport)
  )
  (PRINC)
)					; end of CloseReaction


;;; Starts the reactors
(CmdSpy)
(Create_Close_Reactor)


(princ "\nStartup loaded")
;|«Visual LISP© Format Options»
(120 3 40 2 nil "end of " 100 20 2 0 1 T nil nil T)
;*** DO NOT add text below the comment! ***|;

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...