Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #Modules import
  2. import nuke
  3. import subprocess
  4.  
  5. # Create DateWrite function
  6. def DateWrite():
  7.  
  8. # Create Variables
  9. selectedNodes = nuke.selectedNodes() # Get Selection of all selected nodes
  10.  
  11. if len(selectedNodes) == 1:
  12. filePath = nuke.getFilename('Set Output Directory') # Asks the user to set an OutPut directory for the Write Node
  13.  
  14. writeNode = nuke.createNode("Write") # Create a Write Node
  15. writeNode['file'].setValue(filePath + "[file rootname [file tail [value root.name]]]_[date %y][date %m][date %d]_[date %H][date %M].png") # Set the Write Node with TCL
  16. writeNode['afterRender'].setValue('openDirectoryAfterRender()') # Add a callback which will call the function openDirectoryAfterRender()
  17.  
  18. else:
  19. nuke.message("No node selected or more than one node are selected.nPlease select only one node.")
  20. return filePath
  21.  
  22. # Create openDirectoryAfterRender
  23. def openDirectoryAfterRender():
  24. directoryToOpen = DateWrite() # Get the returned directory from DateWrite() -but also execute DateWrite another time-
  25. directoryToOpen = directoryToOpen.replace('/','\') # Replace the slashes with backslashes
  26.  
  27. subprocess.Popen('explorer %s' % directoryToOpen) # Open the chosen directory
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement