snapShot.py


SnapShot:

snapShot render your current frame result (which ever your seeing your viewer) as a .jpg file and re-load it automatically. Its using your script name, version and your current node   ( means selected node) name.









snapShot.py create a directory called "snapShot"
on your nuke working directory and stores the snapShots into that DIR.























you can modify the snapShots destination DIR and file type as per your need.
  
( I really thank to Nicolas Houle and Frank Rueter for help me out to make this work )

Updated with new icon and custom input gizmo. Place the image gizmo, icon and snapShot.py on your custom nuke DIR. Replace menu.py line to make it work.

Nukepedia: http://www.nukepedia.com/python/render/snapshot/

Download: https://skydrive.live.com/redir.aspx?cid=776f8351d9892b6a&resid=776F8351D9892B6A!256&parid=776F8351D9892B6A!133


else copy paste below code as snapShot.py
'''
Created on 26-Feb-2012
@author: satheesh
mail - satheesrev@gmail.com

Thank to Nicolas to help me out make this work
'''
import nuke
import nukescripts
def snapShot ():
    nodeName = None
    try:
      nodeName = nuke.selectedNode().name()
    except ValueError:  # no node selected
      pass

    if nodeName is not None:
      w = nuke.createNode("Write")
      w.setName("tempWrite")
      w['file'].setValue("[python {nuke.script_directory()}]/snapShots/[string trim [file tail [value root.name]] .nk]_" + nodeName + "_%04d.jpg")
      w['_jpeg_quality'].setValue(1)
      w['_jpeg_sub_sampling'].setValue(2)
      result = nuke.frame()
      if result =="":
        result = result
      nuke.execute(nuke.selectedNode(), (int(result)), result)
      name = w.knob('file').value()
      nukescripts.node_delete(popupOnError=True)
  ## create Read node
      r = nuke.createNode("image")
      r.setName("snapShot")
      r['input'].setValue(name)
      result = nuke.frame()
      r['first'].setValue(int(result))
      r['last'].setValue(int(result))
      r['xpos'].setValue( 200 )

    else:
      nuke.message('select a node to take snapShot')


## create DIR if there is no such directory
def createWriteDir():
    import nuke, os
    file = nuke.filename(nuke.thisNode())
    dir = os.path.dirname( file )
    osdir = nuke.callbacks.filenameFilter( dir )
    try:
        os.makedirs( osdir )
        return
    except:
        return

nuke.addBeforeRender( createWriteDir )



menu.py file:
import snapShot
toolbar.addCommand("Snapshot", "snapShot.snapShot()", icon="/your directory/camera.png", "F3")

( you can change the shortcut from "F3" to what ever you want )

Comments

Post a Comment

Popular posts from this blog

Export Nuke's retime information

Lock and unLock node settings in nuke

Working with UV pass inside NUKE