Author Topic: Timing is key...  (Read 9177 times)

0 Members and 1 Guest are viewing this topic.

rugaroo

  • Bull Frog
  • Posts: 378
  • The Other CAD Guy
Timing is key...
« on: November 03, 2003, 06:41:08 PM »
Hey guys...

Got somewhat of a challenge, or possibly even something a bit more on the easy side. I am in search of a program that will start up every time a user opens a session of ACAD, and it will start a timer. This timer will then start at 00:00:00 (HH:MM:SS), and when a user tells ACAD to clost that file and open a new file, the timer will then stop, place the date, write the amount of time spent on that dwg, and the dwg name into a txt file placed on the users c:\ drive. Now I know that we could start it something like this:

Code: [Select]

(defun-q dwgtimer ()
(princ "\nStarting drawing timer. "
(starttimer)
(princ)
)
(setq s::startup (append s::startup dwgtimer))


Now after watching all of your races, I have come to realize that there is a timer present. To start the timer, you have:

Code: [Select]

(DEFUN starttimer ()
  (SETQ time (GETVAR "date") ;Gets Date
timelog (OPEN "c:\\dwgtimelog.txt" "w") ;<-Added - Creates c:\dwgtimelog.txt also leaves it open for writing.
dwgpre  (getvar "dwgprefix")
dwgnam  (getvar "dwgname")
  )
  (WRITE-LINE DWGPRE
     DWGNAM timelog) ;<-Added - But somehow need to have this write bothe dwgname and prefix...any ideas?
  (WRITE-LINE "Start:" timelog) ;<-Added - Writes line 'Start:'
  (WRITE-LINE (RTOS time 2 6) timelog) ;<-Added - Writes the time...Should be in hours
  (PRINC)
)

(DEFUN endtimer ()
  (SETQ endtime (GETVAR "date")
seconds (* 86400.0 (- endtime time)) ;<-Finds the diff between start and finish
  )
  (WRITE-LINE "\nEnd:" timelog) ;<-Added
  (WRITE-LINE (RTOS endtime 2 6) timelog) ;<-Ending Time...Should be hours
  (WRITE-LINE "Total time:" timelog)
  (WRITE-LINE (RTOS seconds 2 6) timelog) ;<-Total Time...Should be hours again
  (CLOSE timelog) ;<-Closes our dwgtimelog.txt from further editing.
  (PRINC)
)


Now that takes care of the initiation of the timer and what not. Now how can I get it to where endtimer initiates when a user closes a dwg or thier session? Also would I use 'append' to have the prog append to the file each time a user opens a dwg? How would I have the program start by placing the actual date at the beginning of each 'start'?

Hope you guys can help me here :)...I will explain my reasoning later...he he

Rug
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017

hendie

  • Guest
Timing is key...
« Reply #1 on: November 04, 2003, 06:21:32 AM »
oooh cloak and dagger stuff


Code: [Select]
(WRITE-LINE (strcat DWGPRE DWGNAM) timelog)

For your "date" problem, if you have a copy of express tools, have a close look at JULIAN.lsp, specifically the C:DATE function

also, if I were you I would close the text file immediately after writing to it, rather than leaving it open during the session. (just in case !)


there are a couple of problems I can foresee. One being what if a user opens a couple of drawings in succession without closing any. ~ the sequence of your text file could be quite confusing.
This might be  a case for using the USERxx variables. ~ Date / Title / editing time etc ~and writing everything to a text file only when the drawing is closed.
Another problem is catching all the ways a user can exit drawings ~ you could redefine all the exiting commands or write a reactor to catch them.
The writing the code part is relatively easy with the exception of catching the exit method (I think)

SMadsen

  • Guest
Timing is key...
« Reply #2 on: November 04, 2003, 07:01:01 AM »
Like Hendie, I foresee all sorts of troubles with a routine like the one you describe, Rug. It is not a new idea to be able to log username and time spent in the editor, but I have yet to see a totally foolproof solution (personally, I wouldn't touch such a project myself).

Rug, have you considered all the TDxxx system variables? In addition to the static TDCREATE that saves the time for creation, you have 5 dynamic variables to take advantage of.

It might even be that you only have to save the username and TDUSRTIMER to a log when opening a drawing (put it in acaddoc2000.lsp, a .mnl file or where ever you prefer to load it). Then perhaps save the time in a USERRx sysvar or in a dictionary at the same time when the drawing is opened, do a little subtraction next time the drawing is opened and write a record for the new session.

With a little planning ahead to structure it in a decent way, you might even get a satisfactory result without running into the all too many troubles of messing with reactors.

CADaver

  • Guest
Timing is key...
« Reply #3 on: November 04, 2003, 08:33:28 AM »
whhhoooooo buddy...  MDI can-o'-worms properly kicked, lil' buggers wigglin' all over the place.

rugaroo

  • Bull Frog
  • Posts: 378
  • The Other CAD Guy
Timing is key...
« Reply #4 on: November 04, 2003, 10:08:57 AM »
Did I happen to find something that people aren't too  happy to see???? Or are we a tid bit scared???...all well what ever the case be, I am going to see if I can stumble through this one on my knees and find every little crack and niche to be used to my advantage. I know this is something that is a bit on the far side from our usual tasks here, but if it works, hey, all the better, that will just give you guys more code to 'borrow'.

Here goes nothing....

Rug
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017

daron

  • Guest
Timing is key...
« Reply #5 on: November 04, 2003, 10:18:31 AM »
My  boss wants me to come up with something similar, but he's still living in the R-14 world.

hendie

  • Guest
Timing is key...
« Reply #6 on: November 04, 2003, 10:35:51 AM »
give us a clue... give us a clue  :shock:

I can only guess you are trying to come up with some sort of drawing log thingamajig.

i don't suppose it's impossible ~ just that with the MDI and  a few other worms tossed into the can ~ it could be a bit complicated and if not thought out completely beforehand could open up a whole keg of worms.

like Stig mentioned ~I'd stay well clear of reactors and try to keep it relatively simple (relatively speaking !). Stig's idea of
Quote from: Stig
Then perhaps save the time in a USERRx sysvar or in a dictionary at the same time when the drawing is opened, do a little subtraction next time the drawing is opened and write a record for the new session.
is simple yet effective, though you would need to take into account the drawing being opened by several people at different times (another problem)

so let us know what you are up to and we'll tell you if we are up for the task  :P

personally I'd go with the big stick method   :twisted:

daron

  • Guest
Timing is key...
« Reply #7 on: November 04, 2003, 10:47:20 AM »
Oops, I forgot to mention, I'm avoiding that task, by keeping myself busy on other things, not to mention the thought of it is daunting to all the points currently posted against it.

SMadsen

  • Guest
Timing is key...
« Reply #8 on: November 04, 2003, 10:58:26 AM »
Quote from: rugaroo
Did I happen to find something that people aren't too  happy to see???? Or are we a tid bit scared
Nope, not at all. Post your stuff and we'll scare you!  :shock:   :P

rugaroo

  • Bull Frog
  • Posts: 378
  • The Other CAD Guy
Timing is key...
« Reply #9 on: November 04, 2003, 11:52:22 AM »
Ok... here we go...

I have been asked to come up with a sort of spying method on our drafters. We have been seeing mass hours billed to projects, and they have nothing hardly even done on them. As each user enters a dwg, the dwgtimer will start, and post a file on the server which is unaccessible to the given user, but not the software. With this file open, we can tell how long specific users are spending on all projects that they are working on so we can 'baby sit' them. I am not worried if multiple users are in the same dwg, because we will be able to print out the files for all users and compare. As long as we can verify the 'productivity' we will be happy.

Here be de psuedo-code:

Autocad starts/opens dwg
 - DWGTIMER STARTS (from within acad.lsp/acaddoc [which ever])
 - DWGTIMER logs the path and file name for the dwg, and the start time also. This is then in turn written to a file called dwgtimelog.txt.
 - Upon the user opening a new dwg, the dwgtimelog.txt needs to be appended or a new file needs to be created for temp use.
 - As the user exits/closes the dwg, The timer needs to be stopped, and the file needs to be updated to contain the stopping time, and total time spent.
 - After the user exits/closes a dwg, the dwgtimelog will have a new line started for the new dwg that the user has opened.
 - As the user opens and closes dwgs, the txt file will be up dated accordingly.
 - If a user happens to have multiple dwgs open, a tmp file should be able to be created, and then the info written to that tmp file should in turn be able to be taken from that tmp file and placed in the dwgtimelog.txt.

Hopefully this gives you guys a better understanding. :) He he ....who knows???...The Shadow knows all. Bwuahhahahahha. lol :)

Rug
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Timing is key...
« Reply #10 on: November 04, 2003, 12:32:23 PM »
Rug, does your company use custom menus? If so that would be the easiest way to start the program, as SMadsen mentioned earlier. I have something similar to what you are doing, as far as recording the time the dwg was opened that i've used for about a year now.
TheSwamp.org  (serving the CAD community since 2003)

rugaroo

  • Bull Frog
  • Posts: 378
  • The Other CAD Guy
Timing is key...
« Reply #11 on: November 04, 2003, 12:57:29 PM »
Mark -

Custom menu's are just that....Only if the user wants a custom menu. I am the only one in the office that I know of that actually is using a custom menu though.
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017

hendie

  • Guest
Timing is key...
« Reply #12 on: November 05, 2003, 04:27:14 AM »
uhmmnn... [begin ramblings]
what about

    on drawing open
    -> get drawing path, title
    -> get current user, date, time
    -> get TDINDWG value
    -->> store above info in USERxx or dictionary or whatever[/list:u]


    user does their stuff here
    when exiting drawing

      -> get current time
      -> get TDINDWG value again
      -> calculate difference in time
      -> calculate difference in TDINDWG
      -->> write Drawing path, title, date, time spent in dwg, Current User and difference in TDINDWG to text file[/list:u]


      That will give you the Drawing Title, The user, date, the length of time the drawing was open and the amount of time actually spent editing the drawing (big difference !).
      You don't need to worry about multiple drawings being opened as the info is only written out on file close (no temp files). You just need to work out the best way to catch all the ways you can exit a drawing and redefine the commands or whatever.
      Capturing the amount of time the drawing was open and the amount of time actually editing the drawing could tell you a lot. You can have a drawing open all day but only work on it for a few minutes.

      It's my understanding that TDINDWG is only active when the dwg is the active window so if the dwg is open but someone is working on Excel then TDINDWG does not update until the dwg is active again. (I may well be wrong  :oops: ) but it's the closest thing you will get to actual editing time.

      I would try to stay away from having temp files open all over the place. You can get ALL the information you need when the drawing is being closed so why not just write the info out at that point ?
      I'm not entirely sure I agree about the spying bit but using the above "method", you could set it up so that it writes all the info to one file or writes a different log file for each user.

      One warning though. I would be hesitant about taking the values you will get at face value.
      ex. I might have a drawing open all day. I might only work in the drawing for 2 hours but I may have used Excel for another hour doing calculations for that drawing. I may also open another couple of dwg's to sketch in but not save them ~ just copy my sketches into my main dwg (the one being logged). So, my log would show that I had the drawing open for 8 hours while my editing time was only 2 hours but my actual working time for that drawing would be closer to 4 or 5 hours.

      Whatever values you get at the end of the day will be skewed to a certain extent, so you may have to apply a fuzz factor and that may be down to how much you trust each user.
      [/begin rambling]

      CAB

      • Global Moderator
      • Seagull
      • Posts: 10401
      Timing is key...
      « Reply #13 on: November 05, 2003, 08:34:21 AM »
      rug,

      If you need a project, LISP might do it.

      But did you check out
      http://www.sphericaltech.com/timesheet-software.asp

      I just bught it (standard version), works great.

      Each user must log on, so they know they are being watched :)  and
      the time can accurately be used to bill the customer.
      If the key board or mouse is inactive for a pre set time the timer pauses.
      Switch drawings and it is timed, pause for a phone call, you click the icon to start that timer.

      Not trying to sell this but i think you are looking at many hours of development and this is $120.00 US.

      My two cents.

      CAB
      I've reached the age where the happy hour is a nap. (°¿°)
      Windows 10 core i7 4790k 4Ghz 32GB GTX 970
      Please support this web site.

      SMadsen

      • Guest
      Timing is key...
      « Reply #14 on: November 05, 2003, 08:41:17 AM »
      ^ Exactly what I would do .. go find a ready-made and working app for that kind of job.

      When I said that I wouldn't touch such a project, I meant an AutoLISP project. VBA could probably do a good job at it and ARX could most definately do it. AutoLISP could do it, too - but is it worth the trouble?