PDA

View Full Version : Is there a plugin that counts the time you spend working?


JorgeBarros
11-23-2011, 01:09 AM
Hi!

Is there any plugin for Maya that counts the time you spend working on a certain project?

For example, you've been modeling something for 3 months, but you only worked on it 3 or 4 days a week, 5 or 6 hours per day. Also, you have breaks during work time, when you minimize Maya window or simply leave it alone, and you want to know exactly how much time you actually spent working!

Is there any plugin that enables you to control this?

Many thanks in advance for your attention!

zoharl
11-23-2011, 09:55 AM
You could inject a dll into the maya.exe process that monitors the mouse and keyboards events. If less than X time has passed between events, add this time period to your counting table.

thebrianproject
11-26-2011, 05:51 AM
Mel has a command, timerX, i believe. It could probably be saved to an external .txt each time you call it.

JorgeBarros
12-01-2011, 11:19 AM
So for the ones of us that basically don't know much about MEL, there isn't a plugin already created? Because - thank you very much for replying and trying to help, but - I don't have a clue on how to "inject a dll" nor do I understand the information timerX is giving me when I call it...

I find it a little weird that nobody has thought of creating a plugin that lets you know the time you spend working yet, I think it would be useful for lots of people :)

NaughtyNathan
12-01-2011, 11:49 AM
I find it a little weird that nobody has thought of creating a plugin that lets you know the time you spend working yet, I think it would be useful for lots of people :)I think they invented that, it's called a "clock".

Seriously though, I think such a Maya plug-in would be of limited or no use to the vast majority of people. I mean, who actually works exclusively in Maya? no-one I know at least. So all the time you are working in photoshop on your textures, or in Z-brush, or even the time you spend organizing or renaming your files in Windows Explorer. Surely these and many more things you do all count towards the "time spent working on a project". And what about all the time you spend making notes or sketching ideas on the paper and pad next to your keyboard? You cannot equate "time spent moving the mouse" as "time spent working" and neither can you equate it with "time an app is opened". I'm not sure how or what else you could time against.

But you only want a rough ball-park figure? Then invest in a "clock". :)

:nathaN

zoharl
12-01-2011, 11:57 AM
Since what you described isn't specific for maya, I think you should look for a general app, which measures the time spent in a user specified application (or more for Nathan ;) ).

JorgeBarros
12-01-2011, 12:46 PM
Okay then :) Thanks for your point of view, Nathan, really apreciated!
zoharl, that would be a good idea too, I'll see what I can find :)

Thank you.

Keilun
12-01-2011, 03:28 PM
Have a look at ManicTime.

www.manictime.com

We use it to track our hours spent against a certain task. The free version should be sufficient.

kevinsallee
12-01-2011, 05:56 PM
The answers you were given were pertinent, but if you still want something simple i coded this quickly for you. It's two little scripts, you build two shelf buttons with them.
The first is to start a timer when you launch your maya and you opened the file you want to work in:
import maya.cmds as cmds

global workFile
workFile = cmds.file(query = True, sn = True)+".txt"
global startTime
startTime = cmds.timerX()

The next one writes a log file with the same name as your working file+".txt" in the same folder, and writes "Total time: 123.23" Sorry i didnt convert in hours or days, but hey a simple /3600 would do it in hours and you can also use python time conversions. If you want it more complex (days,hours,minutes) i guess i could code you something quickly.

import maya.cmds as cmds
import os

global workFile
global startTime
totalTime = cmds.timerX(startTime = startTime)
if os.path.exists(workFile):
logFile = open(workFile,"r")
currentText = logFile.readline()
totalTime += float(currentText.rpartition(":")[2])
logFile.close()
logFile = open(workFile,"w")
message = "Total time:" + str(totalTime)
logFile.writelines(message)
logFile.close()
startTime = cmds.timerX()

JorgeBarros
12-01-2011, 06:27 PM
Keilun, many thanks, I'll check that one out! While searching for something like that, I found Grindstone, maybe you want to check it, as it might even be of your interest :)

http://www.epiforge.com/Grindstone/

kevinsallee, that was really kind of you, I really appreciate your help! Tell me something, is it possible to make this script stop the timer whenever you switch to another application or simply stop working? That would be exactly what I'm looking for :) If you could code the time result to days,hours,minutes like you said, that would be awesome, I just hope it doesn't steal you much time!

kevinsallee
12-01-2011, 06:51 PM
ok so this would be the code of your second button:

import maya.cmds as cmds
import os

def getInHMS(seconds):
hours = seconds / 3600
seconds -= 3600*hours
minutes = seconds / 60
seconds -= 60*minutes
return "%02d:%02d:%02d" % (hours, minutes, seconds)

def getInSeconds(hmsTime):
timeTable = hmsTime.split(":")
return int(timeTable[0])*3600 + int(timeTable[1])*60+ int(timeTable[2])


global workFile
global startTime
totalTime = cmds.timerX(startTime = startTime)
if os.path.exists(workFile):
logFile = open(workFile,"r")
currentText = logFile.readline()
totalTime += getInSeconds(currentText.partition(":")[2])
logFile.close()
logFile = open(workFile,"w")
message = "Total time:" + getInHMS(int(totalTime))
logFile.writelines(message)
logFile.close()
startTime = cmds.timerX()



and The principle is this one : when you start working, press number 1. If you move to another program, press number 2 to save the total time. When you get back to your file, don't forget to press number 1 again to restart the timer!

kevinsallee
12-01-2011, 07:02 PM
I know that you would prefer something that detects that you're switching software, but maya doesn't have time based callbacks i think, only if you start playing with the API... but with python it's not possible i think

JorgeBarros
12-01-2011, 08:04 PM
That is so awesome, Kevin, thank you very much! I'm sure many more people will find this useful :)

kevinsallee
12-01-2011, 08:09 PM
you're very welcome :) it's a slow day at work anyway... try it a bit and tell me if it works ok for you :)
nice work by the way (saw your blog and your da )

kevinsallee
12-01-2011, 10:49 PM
ok so i changed the code for it to really stop when you use the second bit of the code. That way you really have to press 1 to start the timer

import maya.cmds as cmds

global workFile
global started
started = True
workFile = cmds.file(query = True, sn = True)+".txt"
global startTime
startTime = cmds.timerX()

import maya.cmds as cmds
import os

def getInHMS(seconds):
hours = seconds / 3600
seconds -= 3600*hours
minutes = seconds / 60
seconds -= 60*minutes
return "%03d:%02d:%02d" % (hours, minutes, seconds)

def getInSeconds(hmsTime):
timeTable = hmsTime.split(":")
return int(timeTable[0])*3600 + int(timeTable[1])*60+ int(timeTable[2])

global started
global workFile
global startTime
if started == True:
totalTime = cmds.timerX(startTime = startTime)
if os.path.exists(workFile):
logFile = open(workFile,"r")
currentText = logFile.readline()
totalTime += getInSeconds(currentText.partition(":")[2])
logFile.close()
logFile = open(workFile,"w")
message = "Total time:" + getInHMS(int(totalTime))
logFile.writelines(message)
logFile.close()
started = False


now i'll do the detailed report :)

kevinsallee
12-01-2011, 11:23 PM
Here is the full code for a full report for every time you start/stop :
First code:
import maya.cmds as cmds

global workFile
global started
started = True
workFile = cmds.file(query = True, sn = True)+".txt"
global startTime
startTime = cmds.timerX()

second code:

import maya.cmds as cmds
import os
import datetime

def getInHMS(seconds):
hours = seconds / 3600
seconds -= 3600*hours
minutes = seconds / 60
seconds -= 60*minutes
return "%03d:%02d:%02d" % (hours, minutes, seconds)

def getInSeconds(hmsTime):
timeTable = hmsTime.split(":")
return int(timeTable[0])*3600 + int(timeTable[1])*60+ int(timeTable[2])

global started
global workFile
global startTime
if started == True:
myTime = cmds.timerX(startTime = startTime)
totalTime = 0
currentText = []
if os.path.exists(workFile):
logFile = open(workFile,"r")
currentText = logFile.readlines()
for i in range(0,len(currentText) - 1,1):
totalTime += getInSeconds(currentText[i].partition(":")[2])
logFile.close()
os.remove(workFile)
logFile = open(workFile,"w")
for i in range(0,len(currentText) - 1,1):
logFile.writelines(currentText[i])
if len(currentText) == 0:
versionNumber = 1
else:
versionNumber = len(currentText)
now = datetime.datetime.now()
message = "Session " + str(versionNumber)+ " " + now.strftime("%Y-%b-%d")
message += ": " + getInHMS(int(myTime))+"\n"
logFile.writelines(message)
totalTime += myTime
message = "Total time: " + getInHMS(int(totalTime))
logFile.writelines(message)
logFile.close()
started = False


hope you enjoy it :) i feel like big brother :)

JorgeBarros
12-01-2011, 11:31 PM
You're awesome, it's working great :D

kevinsallee
12-01-2011, 11:34 PM
i just edited the code so it gives you session numbers
session 1, session 2. i edited the post but just in case:

import maya.cmds as cmds
import os
import datetime

def getInHMS(seconds):
hours = seconds / 3600
seconds -= 3600*hours
minutes = seconds / 60
seconds -= 60*minutes
return "%03d:%02d:%02d" % (hours, minutes, seconds)

def getInSeconds(hmsTime):
timeTable = hmsTime.split(":")
return int(timeTable[0])*3600 + int(timeTable[1])*60+ int(timeTable[2])

global started
global workFile
global startTime
if started == True:
myTime = cmds.timerX(startTime = startTime)
totalTime = 0
currentText = []
if os.path.exists(workFile):
logFile = open(workFile,"r")
currentText = logFile.readlines()
for i in range(0,len(currentText) - 1,1):
totalTime += getInSeconds(currentText[i].partition(":")[2])
logFile.close()
os.remove(workFile)
logFile = open(workFile,"w")
for i in range(0,len(currentText) - 1,1):
logFile.writelines(currentText[i])
if len(currentText) == 0:
versionNumber = 1
else:
versionNumber = len(currentText)
now = datetime.datetime.now()
message = "Session " + str(versionNumber)+ " " + now.strftime("%Y-%b-%d")
message += ": " + getInHMS(int(myTime))+"\n"
logFile.writelines(message)
totalTime += myTime
message = "Total time: " + getInHMS(int(totalTime))
logFile.writelines(message)
logFile.close()
started = False

CGTalk Moderation
12-01-2011, 11:34 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.