Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Modules import
- import nuke
- import subprocess
- # Create DateWrite function
- def DateWrite():
- # Create Variables
- selectedNodes = nuke.selectedNodes() # Get Selection of all selected nodes
- if len(selectedNodes) == 1:
- filePath = nuke.getFilename('Set Output Directory') # Asks the user to set an OutPut directory for the Write Node
- writeNode = nuke.createNode("Write") # Create a Write Node
- 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
- writeNode['afterRender'].setValue('openDirectoryAfterRender()') # Add a callback which will call the function openDirectoryAfterRender()
- else:
- nuke.message("No node selected or more than one node are selected.nPlease select only one node.")
- return filePath
- # Create openDirectoryAfterRender
- def openDirectoryAfterRender():
- directoryToOpen = DateWrite() # Get the returned directory from DateWrite() -but also execute DateWrite another time-
- directoryToOpen = directoryToOpen.replace('/','\') # Replace the slashes with backslashes
- subprocess.Popen('explorer %s' % directoryToOpen) # Open the chosen directory
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement