The file you save the code to becomes the module.
So if you save it to "*saveRenderScript*.py", you will have to import
the module *saveRenderScript* in your menu.py, then use
*saveRenderScript.saveRenderScript()
*So try:
import saveRenderScript
nuke.knobDefault('Write.beforeRender',
'saveRenderScript.saveRenderScript()')
Alternatively you could import the function from inside the module into
the global name space like this:
from saveRenderScript import saveRenderScript
the first /saveRenderScript/ is the module (file name), the second one
is the function name inside that file.
If you do it like this, the function now lives in the global name space
and you can use it without referencing the module name:
nuke.knobDefault('Write.beforeRender', 'saveRenderScript()')
Give me a bell if you have any trouble.
Cheers,
frank
On 27/02/14 10:10, jean-luc wrote:
that looks like what I'm after!
I'll give it a go.
so I save a copy of the python script in my ./nuke/python folder under
the name saveRenderScript.py ?
then copy the 2 lines in the menu.py, is that correct?
On 27/02/2014, at 9:30 am, Frank Rueter <[email protected]
<mailto:[email protected]>> wrote:
Hi Jean-Luc,
the way I personally do this is by using the Write nodes'
beforeRender knob. This will execute any python code you give it
every time before a render.
I then use a little script that saves the nuke file and backs up any
previous backup scripts into a hidden folder, so that every tiem you
render, you know you have the respective nuke script in the render
directory.
Here is the code (I just ripped it out of my pipeline code so let me
know if it's missing something):
http://pastebin.com/pq9E1h9k
I then use this line to assign a knob default to the Write nodes'
beforeRender knob:
import nuke
nuke.knobDefault('Write.beforeRender', 'saveRenderScript()')
The above does not modify the nuke script name to reflect the
rendered image's name, but I can add that (after a shower and a
coffee :) ).
Cheers,
frank
On 27/02/14 08:57, jean-luc wrote:
Hi all
I just wanted to ask a little advice/help for a tool I have in my menu.py.
I was given this script and I don't know how to write python so I have no idea
how to modify it, or if it's even possible.
Here is the situation:
The script allows me to save a snapshot of the current script to the active
write nodes folder. I use it to save a backup of the script along the images I
just rendered.
There are a couple of things I'd like to modify if I could.
1 - at the moment, the copy of the nuke script keeps the original name. Could
it be changed to save it with the name of the images rendered in that folder
2 - If I try to run the "copy script" before rendering, it complains because
sometimes the folder doesn't exit yet (It would be created at render time) so I need to
save it after the render. Not ideal as I often forget to do it after the render is done.
Could the script be automatically run at render time instead of having to do it manually?
I was thinking of adding a check box in the write node that would automatically run the
"copy script" each time you press the render button. I would always keep it on
by default.
I hope this make sense.
It's a very useful tool and I'd love to see it work automatically. It's a life
saver!
script is attached.
Cheers
Jean-Luc
_______________________________________________
Nuke-python mailing list
[email protected],http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
[email protected]
<mailto:[email protected]>,
http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python