BlackBox Posted October 25, 2012 Posted October 25, 2012 I was in a similar situation not that long ago myself. I have not read this entire thread, so I'll try to be brief in my explanation, as an effort to help you try to develop your own thought for this task: Like many things in life, in order to accomplish something, you need a plan. What makes up your plan can be summed up as being one of two things... Specified, and Implied tasks. A specified task for your situation would be to log how long a drawing was opened for when said drawing is closed. But there are several things Implied that are required to fulfil the Specified task. For example, you need to know the drawing name that was opened, and at when to start your timer. You must also identify what should trigger your log file entry, where your log file should be located, what to do if the log file does not exist (either by accidental deletion, or on a new computer with no log file), etc.. Usually, I don't have all of the answers when I start out on a routine... Often times there is a lot of trial and error, reading either documentation or old posts all to try and teach myself how to overcome a given hurdle. Sometimes, I just don't have time for that, and make a post... I am very blessed to have had much help from others much, much smarter than I, and a Fiancé patient enough to tolerate my coding habits! LoL If I can be of further help, please let me know. Quote
CadFrank Posted October 25, 2012 Author Posted October 25, 2012 Well I'll round up my plan and start my coding for now. I find it hard because out of work I dont always have the time to focus all my attention in coding. But your insites are helpfull and appreciated. Ill see you get some updates on my progresse Cheers ! Quote
CadFrank Posted October 25, 2012 Author Posted October 25, 2012 (edited) (vl-load-com) (defun _FilePath->List (filePath / i folder folders) (setq filePath (vl-string-translate "\\" "/" filePath)) (while (setq i (vl-string-search "/" filePath)) (setq folders (cons (setq folder (substr filePath 1 i)) folders)) (setq filePath (substr filePath (+ 2 i))) ) (reverse folders) ) (defun c:Timetracker (/ PrNam Wline file) (setq Wline (strcat (nth 2 (_FilePath->LIST (getvar 'dwgprefix))) " - " (menucmd ;;; "M=$(edtime,$(getvar,date),YYYY/MO/DD - HH:MM AM/PM)" ; 12 hour clock "M=$(edtime,$(getvar,date),YYYY/MO/DD - HH:MM)" ; 24 hour clock ) " - " (getstring "\nAdditionnal Information : ") ) ) (setq file (findfile "C:\\Users\\francois.levesque\\Documents\\test.txt")) (setq file (open file "a")) (write-line wline file) (close file) (prompt "\nProject name, Date & Time printed in file Timetracker.txt ") (princ) ); defun c: Edited October 25, 2012 by CadFrank Quote
BlackBox Posted October 25, 2012 Posted October 25, 2012 Well I'll round up my plan and start my coding for now. I find it hard because out of work I dont always have the time to focus all my attention in coding. But your insites are helpfull and appreciated. Ill see you get some updates on my progresse Cheers ! In my limited experience, anything worth doing, does (take time)... I'm glad you found my $0.02 helpful. ------------------------------------------------------------ (vl-load-com) (defun _FilePath->List (filePath / i folder folders) (setq filePath (vl-string-translate "\\" "/" filePath)) (while (setq i (vl-string-search "/" filePath)) (setq folders (cons (setq folder (substr filePath 1 i)) folders)) (setq filePath (substr filePath (+ 2 i))) ) (reverse folders) ) (defun CDT (/ d yr mo day hr m Cdate Ctime) (setq d (rtos (getvar "CDATE") 2 6) yr (substr d 3 2) mo (substr d 5 2) day (substr d 7 2) hr (substr d 10 2) m (substr d 12 2) ) (setq Cdate (strcat day "/" mo "/" yr) Ctime (strcat hr ":" m) ) (princ) );defun (defun c:Timetracker (/ PrNam Wline) (setq PrNam (nth 2 (_FilePath->LIST (getvar 'DWGPREFIX)))) (setq Wline (strcat PrNam " - " Cdate " - " Ctime)) ); defun c: Consider this adaptation (using your string format): (defun _GetCurrentProjectAndTime () (strcat (nth 2 (_FilePath->LIST (getvar 'dwgprefix))) " - " (menucmd ;;; "M=$(edtime,$(getvar,date),YYYY/MO/DD - HH:MM AM/PM)" ; 12 hour clock "M=$(edtime,$(getvar,date),YYYY/MO/DD - HH:MM)" ; 24 hour clock ) ) ) Quote
CadFrank Posted October 25, 2012 Author Posted October 25, 2012 Ok So I made changes to the code and it gives me what I want. Thing is there are 2 things I want to do. I want to add Additionnal information. So A few words. The other thing would be to make the program load when I press CTL + S. I know it's something I can change in the CUI but not to sure what. But I Would be wondering if I could input an auto save in it. Later I would also like to import it to an excel Sheet Anywho's .. Idea's ?? 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.