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




#copy nuke script to the active write nodes folders
import shutil
import os.path
def SaveScriptToWriteDir():
    script = nuke.root().name() 
    for n in nuke.allNodes("Write"):
        if not n["disable"].value():
             dest = os.path.dirname(n["file"].value()) + '/' + os.path.basename(script)
             if script != dest:
                print "SaveScriptToWriteDir: Saving", script, "to", dest
                shutil.copyfile(script, dest)
             else:
                print "SaveScriptToWriteDir: Cannot copy", script, "to", dest

m = menubar.addMenu("&File")
m.addCommand("Save Script To Active Write Dirs", 'SaveScriptToWriteDir()')


_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to