fcfcadd Posted January 26, 2010 Share Posted January 26, 2010 I am looking for a program in either lisp or vba to keep track of time. I have seen the "Drawing Log" post put up by "russell84" and the response by "borgunit" but neither of them keep track of the total time spent within that file. They just post the user, date with time opened, and the file. I need one that posts the time spent or end time as well. In other words I want to know how long I spent in each drawing file if it was 1 second or 8 hours. I'd like the format to be: USER | DATE AND TIME OPENED | DATE AND TIME CLOSED | TOTAL AMOUNT OF TIME | FILE. Can this be done is the other question. Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted January 26, 2010 Share Posted January 26, 2010 What happens if you open a drawing, walk away for 4 hours and then return? Should that count for 4 hours? If not, how would you proposed "time spent" be accounted for? Quote Link to comment Share on other sites More sharing options...
CADMASTER1128 Posted January 26, 2010 Share Posted January 26, 2010 Have you tried the TIME command? Quote Link to comment Share on other sites More sharing options...
fcfcadd Posted January 26, 2010 Author Share Posted January 26, 2010 For me it doesn't matter if I walk away for 4 hours or not or if I'm sitting there actually working on it. Personally for my situation if I'm done with a drawing then I close it. I don't leave AutoCAD opened if I'm not in it using it. No I have not tried TIME command. I have only tried the lisp program that was posted on that other thread. Quote Link to comment Share on other sites More sharing options...
Tiger Posted January 27, 2010 Share Posted January 27, 2010 I use a good old-fashioned notebook, because like RK said, there is no way that a time-log would accuratly describe exactly how many hours you have worked on a drawing. Did you close AutoCAD down when you wrote this thread? When you talk to you co-workers? When you get a cup of coffe? bathroom break? I get that it's good to know a ballpark figure on how many hours a drawing takes, and again - a notebook is accurate enough in my opinion. Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted January 27, 2010 Share Posted January 27, 2010 Agree with Tiger... Having said that.... http://www.autojournal.net/ used to host an old program in VBA that wrote out data to Outlook. I don't know what criteria it used to determine the time, other than how long the drawing was open. Currently my firewall is blocking this URL so it may have changed to something else....? Quote Link to comment Share on other sites More sharing options...
fcfcadd Posted January 27, 2010 Author Share Posted January 27, 2010 Yes I did close out of AutoCAD when typing this. Like I said before when I'm not working in AutoCAD I close it down. I am self employeed so keeping accurate time is very important to me and when you switch between 5 or 10 jobs a day the notebook option is a pain in the but. That's why I would rather have something electronicly track the time spent. I'll check into the autojournal option as well. Quote Link to comment Share on other sites More sharing options...
dbroada Posted January 27, 2010 Share Posted January 27, 2010 if you only want total drawing open time then cadmaster's TIME will give what you want. Quote Link to comment Share on other sites More sharing options...
fcfcadd Posted January 27, 2010 Author Share Posted January 27, 2010 How do I use that to have it automatically log the time to a file. Is there a program that does that? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 27, 2010 Share Posted January 27, 2010 How do I use that to have it automatically log the time to a file. Is there a program that does that? The values that the TIME command uses are stored in the Sys Vars: TDINDWG, TDCREATE, TDUPDATE, TDUSRTIMER A simple LISP could write these values to a file. Quote Link to comment Share on other sites More sharing options...
fcfcadd Posted January 27, 2010 Author Share Posted January 27, 2010 It's been over ten years since I've wrote a lisp routine. I wouldn't know how to put it together. Basicly I'm asking if someone could put a simple one together for me in either lisp or vba. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 27, 2010 Share Posted January 27, 2010 Example: (defun c: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 (or *logfile* (setq *logfile* (getfiled "Create Log File" "" "txt" 1))) (progn (setq ofile (open *logfile* "a")) (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)) Quote Link to comment Share on other sites More sharing options...
fcfcadd Posted January 27, 2010 Author Share Posted January 27, 2010 I'll give that a try and see if I can get it to run automaticlly. Thank you so much. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 27, 2010 Share Posted January 27, 2010 I'll give that a try and see if I can get it to run automaticlly. Thank you so much. When you say automatically, what do you mean? When the drawing is saved? If you want it to run automatically, you will need to maybe use it as a callback function in a reactor, triggered on the save command. Quote Link to comment Share on other sites More sharing options...
fcfcadd Posted January 27, 2010 Author Share Posted January 27, 2010 I would need it to run on the open command and on the close command. So each time i opened a new drawing and then when I closed that drawing. Even if I had to answer a prompt at close for it to run would be fine too. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 27, 2010 Share Posted January 27, 2010 You could use a Command Reactor, to react after the open command has ended, and as the close command is started. Here is a good bit of help on reactors, http://www.afralisp.net/vl/reactors1.htm And there is also some good stuff in the Visual LISP Help files Quote Link to comment Share on other sites More sharing options...
fcfcadd Posted January 27, 2010 Author Share Posted January 27, 2010 Yeah I've been on that web site before and he used to have a vba program that kept track of time on there as well but It has some bugs in it right now and I can't get it to work right. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 27, 2010 Share Posted January 27, 2010 This should work for you: (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)) Place the code into your ACADDOC.lsp, so that it runs when you open the drawing. You can enter TIMEOFF to disengage the reactor at any time. Lee Quote Link to comment Share on other sites More sharing options...
fcfcadd Posted January 27, 2010 Author Share Posted January 27, 2010 I will give it a shot and see what happens. Thank you so much. If this works this will save me a ton of headaches and a ton of time. Quote Link to comment Share on other sites More sharing options...
fcfcadd Posted January 27, 2010 Author Share Posted January 27, 2010 When I open up a drawing in autocad everything starts up good but I'm not seeing where it places the log file Quote Link to comment Share on other sites More sharing options...
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.