JoeyG_77 Posted April 21, 2015 Posted April 21, 2015 Hey everyone ... I need some help and I have noooo idea where to start or how to write the code needed to do my thought. I need a text file that gives a marker when you open and close a drawing w/ a time stamp and so i can track my day w/o trying to figure out how many hours I worked on a drawing. This has to be a continuous list for the day. There was a previous post from 2010 which worked great but it put an individual text file in each drawing location. I need one text file so i can see all the drawings that were opened and closed w/ the time & date..... So any help would be much appreciated Joey G Quote
Commandobill Posted April 21, 2015 Posted April 21, 2015 Maybe you should consider modifying the lisp routine you have to only put it into one file. Quote
JoeyG_77 Posted April 21, 2015 Author Posted April 21, 2015 I have no idea where to even begin ... This is the code i received from the forum (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 (getvar 'DWGPREFIX) (getvar 'DWGNAME) "_log.txt") "a")) (progn (write-line (strcat "DATE: " (toDate "DATE" "DD.MO.YY HH.MM.SS")) ofile) (write-line (strcat "DRAWING: " (getvar 'DWGPREFIX) (getvar 'DWGNAME)) ofile) (write-line (strcat "CREATED: " (toDate "TDCREATE" "DD.MO.YY HH.MM.SS")) ofile) (write-line (strcat "TOTAL EDITING TIME: " (toDate "TDINDWG" "HH.MM.SS") "\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)) Quote
Commandobill Posted April 21, 2015 Posted April 21, 2015 Ok, the line you want to change is this one: (if (setq ofile (open (strcat (getvar 'DWGPREFIX) (getvar 'DWGNAME) "_log.txt") "a")) If you let me know the exact location and file name I can change it for you. Otherwise, you would change : (setq ofile (open (strcat (getvar 'DWGPREFIX) (getvar 'DWGNAME) "_log.txt") "a")) to something like : (setq ofile (open "C:\\somefilename.txt" "a")) The double backslash is key. Quote
JoeyG_77 Posted April 21, 2015 Author Posted April 21, 2015 C:\Users\Acad2015\TimeLog\Logfile.txt also would this create a new file everyday .. its a silly question but still wanted to ask =) Quote
tzframpton Posted April 21, 2015 Posted April 21, 2015 There's always CAD Tempo: http://www.cadtempo.com/ It's cheap and highly versatile. Quote
Commandobill Posted April 21, 2015 Posted April 21, 2015 Here's the new code: ;;I believe this was originally written by Lee-Mac ;;Date: Unknown ;;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 "C:\\Users\\Acad2015\\TimeLog\\Logfile.txt" "a"));;Location of change (progn (write-line (strcat "DATE: " (toDate "DATE" "DD.MO.YY HH.MM.SS")) ofile) (write-line (strcat "DRAWING: " (getvar 'DWGPREFIX) (getvar 'DWGNAME)) ofile) (write-line (strcat "CREATED: " (toDate "TDCREATE" "DD.MO.YY HH.MM.SS")) ofile) (write-line (strcat "TOTAL EDITING TIME: " (toDate "TDINDWG" "HH.MM.SS") "\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)) C:\Users\Acad2015\TimeLog\Logfile.txtalso would this create a new file everyday .. its a silly question but still wanted to ask =) We could always change the code to create a new text file each day, but currently it does not. Quote
Commandobill Posted April 21, 2015 Posted April 21, 2015 There's always CAD Tempo: http://www.cadtempo.com/ It's cheap and highly versatile. Blasphemy! Coming into a LISP thread and trying to make people buy stuff... Quote
JoeyG_77 Posted April 21, 2015 Author Posted April 21, 2015 27th Jan 2010 was the date he wrote it ... This was the original thread : http://www.cadtutor.net/forum/archive/index.php/t-44196.html Thanks sooo much Bill im testing it now =) Quote
JoeyG_77 Posted April 21, 2015 Author Posted April 21, 2015 (edited) This is the text from the file it gives DATE: 04.21.15 13.05.26 DRAWING: X:\Churchill\Engineering\JohnsBedroom\ChurchHill_JohnsBedroom_Rev0.dwg CREATED: 04.17.15 12.35.19 TOTAL EDITING TIME: 03.03.43 Bill is there a way to catch the action such as like .. ACTION:OPEN DATE: 04.21.15 13.05.26 DRAWING: X:\Churchill\Engineering\JohnsBedroom\ChurchHill_JohnsBedroom_Rev0.dwg ACTION:CLOSED DATE: 04.21.15 13.05.26 DRAWING: X:\Churchill\Engineering\JohnsBedroom\ChurchHill_JohnsBedroom_Rev0.dwg Edited April 21, 2015 by JoeyG_77 MisTyped info Quote
tzframpton Posted April 21, 2015 Posted April 21, 2015 Blasphemy! Coming into a LISP thread and trying to make people buy stuff... Lol, sorry Bill. Just giving an alternative resource is all. Quote
Patrick Hughes Posted April 21, 2015 Posted April 21, 2015 There's always CAD Tempo: http://www.cadtempo.com/ It's cheap and highly versatile. I prefer the term 'inexpensive" or "reasonably priced" But I like the highly versatile and I thank you for the mention Tannar. Quote
Commandobill Posted April 21, 2015 Posted April 21, 2015 I'm sure there us a much more elegant way of doing this... ;;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 "C:\\Logfile.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" "DD.MO.YY HH.MM.SS")) ofile) (write-line (strcat "DRAWING: " (getvar 'DWGPREFIX) (getvar 'DWGNAME)) 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)) Quote
Commandobill Posted April 21, 2015 Posted April 21, 2015 Lol, sorry Bill. Just giving an alternative resource is all. Ha! I was just messing with you. I'm sure it's a good program. Quote
JoeyG_77 Posted April 21, 2015 Author Posted April 21, 2015 (edited) Bob This is perfect !!! BUT !!! ... is there a way to add a space between each grouping =) This is the code I have .. Made some tweaks ;;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 "C:\\Users\\Acad2015\\TimeLog\\Logfile.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)) 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)) Edited April 22, 2015 by JoeyG_77 WRONG CODE !! .... SORRY BILL Quote
JoeyG_77 Posted April 21, 2015 Author Posted April 21, 2015 This is the file I am getting ... Now ACTION: OPENED DATE: 04.21.15 15.22.02 DRAWING: X:\Churchill\Engineering\MasterBedroom208\ChurchHill_MasterBedroom208_Rev0.dwg ACTION: OPENED ACTION: OPENED DATE: 04.21.15 TI4E 15.25.45 DRAWING: X:\Holliday 2\Engineering\Parlor\Holliday_Parlor_Rev0.dwg ACTION: OPENED DATE: 04.21.15 ** 15.26.43 DRAWING: X:\Holliday 2\Engineering\Parlor\Holliday_Parlor_SM.dwg Is there a way to get it to look like this below .... ACTION: OPENED DATE: 04.21.15 15.22.02 DRAWING: X:\Churchill\Engineering\MasterBedroom208\ChurchHill_MasterBedroom208_Rev0.dwg ACTION: OPENED DATE: 04.21.15 TI4E 15.25.45 DRAWING: X:\Holliday 2\Engineering\Parlor\Holliday_Parlor_Rev0.dwg ACTION: OPENED DATE: 04.21.15 ** 15.26.43 DRAWING: X:\Holliday 2\Engineering\Parlor\Holliday_Parlor_SM.dwg Quote
BIGAL Posted April 22, 2015 Posted April 22, 2015 Another to have a look at Productivity_analysis.lsp logs a single dwg but only 1 file per dwg even over multiple days and logs commands etc used. Quote
JoeyG_77 Posted April 22, 2015 Author Posted April 22, 2015 I have everything I need .... but i just need it to separate it in the log !! ..... its gotta be easy but i just dont know what is missing . Quote
Commandobill Posted April 22, 2015 Posted April 22, 2015 I forgot to add the "\n" for new line in the code. My bad. ;;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 "C:\\Users\\Acad2015\\TimeLog\\Logfile.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)) Quote
JoeyG_77 Posted April 22, 2015 Author Posted April 22, 2015 Bill you are a rockstar !!! ... This is perfect is there any way to add a variable that will change the date daily ... so there would be a list of logs for the week so during that day it will write to the same file and then the next it would do the same to that days date .. (if (setq ofile (open "C:\\Users\\Acad2015\\TimeLog\\Logfile-[color="red"][b]DATEVARIBLE[/b][/color].txt" "a"));;Location of change Quote
Recommended Posts
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.