Hi Terrycad!
Thanks for posting the code and links, much appreciated!
It's been an amazing long while since I posted this question, I'm glad you took the time to post some helpful code. Below is the code in my acaddoc.lsp that currently appends to a .txt file, previous to that, the only change, I believe, was appending to a .xlsx file, which worked for quite a while and then stopped suddenly. Hence, I inserted the .log file instead. Here's the code used to append to the .log file:
(if (not (wcmatch (getvar 'DWGNAME) "Drawing*.dwg"))
(progn
(setq begin_time (getvar "tdusrtimer"))
(vl-load-com)
(princ "\nTime marches on!!!\n")
(if (/= 'VLR-Command-Reactor (type ReactorCommandWillStart))
(setq ReactorCommandWillStart
(vlr-command-reactor nil
'((:vlr-commandWillStart . CallbackCommandWillStart))
)
)
)
(defun CallbackCommandWillStart ( reactor cmdInfo / cmdName )
(cond
( (eq "CLOSE" (setq cmdName (car cmdInfo)))
(CADLOG-close)
)
)
)
(defun cadlog-open ()
(setq open_time (getvar "cdate")
date_lbl-open (strcat (thedate3 open_time "_"))
;log_file (open (strcat "C:\\Users\\jkaufman\\Documents\\dwgslog.log") "a")
);setq
;(write-line
;(strcat "**Opened\t"
;(thedate3 open_time "-")
;"\t"
;(thetime3 open_time nil)
;"\t"
;job_no
;dwg_no
;)
;log_file
;)
;(close log_file)
)
(defun cadlog-close (/ user_name job_no dwg_no close_time log_file)
(setq job_no (getvar "dwgprefix")
dwg_no (getvar "dwgname")
close_time (getvar "cdate")
end_time (getvar "tdusrtimer")
date_lbl-close (strcat (thedate3 close_time "_"))
time_worked (rtos (/ (/ (* (- end_time begin_time) 86400) 60) 60) 2 3)
time_worked2 (/ (/ (* (- end_time begin_time) 86400) 60) 60)
t_w_m (rtos (* (atof time_worked) 60) 2 3)
t_w_m2 (* time_worked2 60)
min-num (fix t_w_m2)
t_w_s (rtos (* (- t_w_m2 min-num) 60) 2 2)
log_file (open (strcat "C:\\Users\\jkaufman\\Documents\\dwgslog.txt") "a")
)
(write-line
(strcat "**Opened\t"
(thedate3 open_time "-")
"\t"
(thetime3 open_time nil)
"\t"
job_no
dwg_no
"\t"
"**Closed\t"
(thedate3 close_time "-")
"\t"
(thetime3 close_time nil)
"\t"
(strcat time_worked " hrs.")
"\t"
(strcat (itoa min-num) " min. " t_w_s " sec.")
)
log_file
)
(close log_file)
(princ "\nTime marched on!!!\n")
)
(defun thedate3 (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)
"-"
(substr date1 7 2)
"-"
(substr date1 1 4)
)
) ;_ end defun thedate3
(defun thetime3 (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 thetime3
(CADLOG-open)
);end progn
);end if
This is the output in the .txt log file:
"**Opened 04-07-2020 13:12:19 W:\cust\E2055020.dwg **Closed 04-07-2020 13:14:44 0.040 hrs. 2 min. 24.21 sec.
**Opened 04-07-2020 13:18:58 W:\cust\E2055020.dwg **Closed 04-07-2020 13:21:52 0.048 hrs. 2 min. 54.33 sec.
**Opened 04-08-2020 06:29:43 W:\cust\ASSET 367726.dwg **Closed 04-08-2020 06:31:53 0.036 hrs. 2 min. 9.84 sec.
**Opened 04-08-2020 09:19:10 W:\cust\INLET POST B PLATE.dwg **Closed 04-08-2020 09:20:14 0.018 hrs. 1 min. 3.66 sec." ("cust" would be in place of the actual customer name).
How would you adjust your code to have the next line of text for the spreadsheet automatically start in the next row down?
Thank you!
Drafter_Joe