PDA

View Full Version : Nuke timer gizmo



nofxboy1234
May 8th, 2010, 08:44 AM
Hi :)

What would be the best way to create a gizmo that allows a user to start and stop a timer, to see how long it takes you to get a task done, and maybe log the times for each session. An example is rotoscoping an object in a shot. I am going through the nuke gizmo tutorial videos on their site to see if i can find a method. How would you create a custom gizmo from scratch, or would you make a group into a gizmo and start from there?

Thanks

jokerxel
May 8th, 2010, 11:41 AM
I would say to create a timer gizmo:
1. one python script button would run a python script that displays/logs the current time
2. another python script button runs a second script that logs the end time
3. maybe a third python script button that would run a function that calculates the difference between both times, and displays it or logs it to a separate file.

this should help you get started:

from datetime import datetime
datetime.now()

# Result: datetime.datetime(2010, 5, 8, 9, 35, 30, 847000)
# or if you do...

print datetime.now()
# Result: 2010-05-08 09:37:00.966000

nofxboy1234
May 8th, 2010, 12:10 PM
Cool, thanks! :)

I will try that out.

MisterSchroeder
May 8th, 2010, 12:46 PM
Cut and paste the attached node into Nuke. It is a NoOp node with some Python buttons. I used python's 'time' module to get the current system time.

For making it a gizmo: Either turn it into a group and then into a gizmo (you probably will have to do the UI part again...) or save it as a script that you then call by a line like this in your menu.py:

m=menubar.addMenu('MyTools')
m.addCommand('Stopwatch', "nuke.nodePaste('path/to/the/script/stopwatch.nk')")

here is the node:

set cut_paste_input [stack 0]
version 5.1500
push $cut_paste_input
NoOp {
name StopWatch
selected true
xpos 31
ypos -81
hide_input true
addUserKnob {20 User}
addUserKnob {7 Start}
addUserKnob {7 End}
End 1
addUserKnob {7 Duration}
Duration {{End-Start}}
addUserKnob {26 ""}
addUserKnob {22 Start_1 l Start T "import time\nt = time.time()\nnuke.thisNode()\['Start'].setValue(t)" +STARTLINE}
addUserKnob {22 Stop T "import time\nt = time.time()\nnuke.thisNode()\['End'].setValue(t)\ndur = nuke.thisNode()\['Duration'].value()\nmin = (dur/60)\nsec = (((dur/60) - int(dur/60))*100)\nseconds = sec/100*60\n\nnuke.message(str(int(min)) + \" min, \" +str(int(seconds)) + ' sec')" +STARTLINE}
}

Happy speed-rotoscoping!

nofxboy1234
May 8th, 2010, 12:49 PM
Thanks very much for the feedback :)

nofxboy1234
May 8th, 2010, 12:54 PM
I just tried that node now and it works perfectly! :D Just what I was looking for. Thanks again.

Dotcommer
May 8th, 2010, 08:27 PM
Huh, thats pretty cool. Just tried it myself. So how would you go about modifying it so that it stores the time and adds on to it? I'm thinking this would be cool to be able to log your time in a script, and then close it out for the day, and come back to it in the morning and keep working, and at the very end, find out the total time spent working in the script.

MisterSchroeder
May 9th, 2010, 01:48 AM
Here is your accumulative timer. But don't tell your Producers about it. They'll want to pay you by the second now ;-)

set cut_paste_input [stack 0]
version 5.1500
push $cut_paste_input
NoOp {
name StopWatch
selected true
xpos -92
ypos -139
hide_input true
addUserKnob {20 User}
addUserKnob {20 Store n 1}
Store 0
addUserKnob {7 Start}
addUserKnob {7 End}
End 1
addUserKnob {7 Duration}
Duration {{End-Start}}
addUserKnob {7 Total}
addUserKnob {20 endGroup n -1}
addUserKnob {26 ""}
addUserKnob {22 Start_1 l Start T "import time\nt = time.time()\nnuke.thisNode()\['Start'].setValue(t)" +STARTLINE}
addUserKnob {22 Stop -STARTLINE T "import time\nt = time.time()\nnuke.thisNode()\['End'].setValue(t)\ndur = nuke.thisNode()\['Duration'].value()\nnuke.thisNode()\['Start'].setValue(t)\nmin = (dur/60)\nsec = (((dur/60) - int(dur/60))*60)\n\ntotal = nuke.thisNode()\['Total'].value()\nnewTotal = total + dur\nnuke.thisNode()\['Total'].setValue(newTotal)\n\nnuke.message(str(int(min)) + \" min, \" +str(int(sec)) + ' sec')"}
addUserKnob {22 Total_1 l Total T "dur = nuke.thisNode()\['Total'].value()\nmin = (dur/60)\nsec = (((dur/60) - int(dur/60))*60)\n\nnuke.message(str(int(min)) + \" min, \" +str(int(sec)) + ' sec')" +STARTLINE}
addUserKnob {22 Reset -STARTLINE T "nuke.thisNode()\['Total'].setValue(0)"}
}

nofxboy1234
May 9th, 2010, 03:03 AM
Awesome! :)

Dotcommer
May 9th, 2010, 05:37 AM
Damn, thats great. Thanks for doing that.