-
Notifications
You must be signed in to change notification settings - Fork 40
Documentation
The Nuke Write Node App provides a custom Shotgun Write node which makes it easy to standardise the location where images are rendered to. It can be configured for each environment. In addition to the path, the configuration will also determine the node name and render format to be used.
In order to use the Shotgun Write Node, save your script as a Toolkit work file first and then create a new node via the Nuke menu. This will create a node which looks similar to a normal write node:
Rather than entering a path by hand, you just specify a channel and the Toolkit will compute the rest of the path automatically. You can see the computed path in the UI and open up the location on disk by clicking the Show in File System button. The location where the renders are written to depends on the Toolkit configuration.
You can use the value of the channel knob to help differentiate multiple write nodes in a single file. Channel names are unique within a file, and should be thought of as the name of the Write Node. The label on the node will reflect the channel name and since the channel is used in the filename, you will be able to find the node in a scene that rendered out the file:
The renders will be versioned and the version number will always follow the current nuke script version which will be incremented automatically when you publish using Multi Publish.
The Write Node will cache the current path so that it is still valid if the file is opened outside a Toolkit Work Area. Occasionally, this can mean that the path becomes out of sync and 'locked'. If the render path is locked then renders created with this Write Node cannot be published.
To reset a render path, either version-up the scene using the Work-files app's 'Version Up Scene' command or select the Write node individually and in the properties, click Reset Path:
It's common for studios to use a render farm running job management tools (e.g. Deadline) which would typically launch Nuke directly when rendering. Because this is outside of the Shotgun environment, the tk-nuke-writenode app and the Write Node gizmo will not be found without some additional help.
Whilst we are experimenting with a more complete solution, the following is a minimal bootstrap of the tk-nuke engine so that Shotgun Write Nodes behave as expected.
Nuke will run any init.py
scripts found in it's plug-in path - see [here http://docs.thefoundry.co.uk/nuke/63/pythondevguide/startup.html
] for more details.
The following example init.py script should be placed in one of these locations and this will ensure that the tk-nuke engine is loaded correctly.
# Save this file as init.py in your nuke plug-in path as described here:
#
# http://docs.thefoundry.co.uk/nuke/63/pythondevguide/startup.html
#
def init_sgtk(studio_root, default_work_area_path):
"""
Minimal setup to ensure the tk-nuke engine is up
and running when Nuke is started outside or the
Tank command or Shotgun context menus
"""
import sys, os
# make sure sgtk module can be found in the python path:
core_python_path = os.path.abspath(os.path.join(studio_root, "tank/install/core/python"))
if core_python_path not in sys.path:
sys.path.append(core_python_path)
# Check that we need to start the engine:
if "TANK_ENGINE" in os.environ:
# tk-nuke engine is going to be set up by
# tk-multi-launchapp so we don't need to bother
return
# Check that the engine isn't already running
if "TANK_NUKE_ENGINE_MOD_PATH" in os.environ:
# tk-nuke engine is running which will handle all
# engine & context management from now on
return
# initialize tk-nuke engine:
try:
# Determine the work area path that will be used to
# create the initial context the engine will be
# started with. If a file path was specified on the
# command line then this will be sys.argv[0]
work_area_path = default_work_area_path
if len(sys.argv) > 0 and sys.argv[0].endswith(".nk") and os.path.exists(sys.argv[0]):
# file path was passed through the command line
work_area_path = sys.argv[0]
import sgtk
tk = sgtk.Sgtk(default_work_area_path)
ctx = tk.context_from_path(work_area_path)
sgtk.platform.start_engine("tk-nuke", tk, ctx)
except Exception, e:
print "Failed to start Toolkit Engine - %s" % e
# pass in sensible values for studio_root & default_work_area_path
studio_root = "/studio_root" # The location of the Toolkit code on disk
default_work_area_path = "/project_root/my_project" # The default work area to be used if no .nk file is specified on the command line
init_sgtk(studio_root, default_work_area_path)
You will need to modify this script to provide your specific studio/code and project roots - you may also need to extend this if your configuration is more complex than this example or you are passing a python script to the command line using the -t
flag instead of a nuke (.nk) script.
Deadline can copy Nuke scripts to a temporary location when rendering. This will cause problems with the Toolkit as the files will no longer be in a disk location that it recognises. To disable this behaviour and load the scripts from their original location:
- In Deadline, navigate to Tools > Configure Plugin (In the super user mode)
- Disable the option 'Enable Path Mapping'
The following API methods are available on the App:
Return a list of all Shotgun Write Nodes in the current scene.
list
app.get_write_nodes()
Parameters & Return Value
-
Returns:
list
- a list of Toolkit Write nodes found in the scene
Example
>>> import sgtk
>>> eng = sgtk.platform.current_engine()
>>> app = eng.apps["tk-nuke-writenode"]
>>> nodes = app.get_write_nodes()
Return the name of the specified Write Node.
string
get_node_name(node
node)
Parameters & Return Value
-
node
node - the Write Node to query -
Returns:
string
- the name of the node.
Example
>>> import sgtk
>>> eng = sgtk.platform.current_engine()
>>> app = eng.apps["tk-nuke-writenode"]
>>> nodes = app.get_write_nodes()
>>> app.get_node_name(nodes[0])
Get the name of the configuration profile used by the specified Write node.
string
get_node_profile_name(node
node)
Parameters & Return Value
-
node
node - the Write Node to query -
Returns:
string
- the profile name for this Write Node as defined by the configuration
Example
>>> import sgtk
>>> eng = sgtk.platform.current_engine()
>>> app = eng.apps["tk-nuke-writenode"]
>>> nodes = app.get_write_nodes()
>>> app.get_node_profile_name(nodes[0])
Get a list of all image files that have been rendered for the specified Write Node.
list
get_node_render_files(node
node)
Parameters & Return Value
-
node
node - the Write Node to query -
Returns:
list
- a list of the image files rendered by this Write node.
Example
>>> import sgtk
>>> eng = sgtk.platform.current_engine()
>>> app = eng.apps["tk-nuke-writenode"]
>>> nodes = app.get_write_nodes()
>>> app.get_node_render_files(nodes[0])
Get the template that determines where rendered images will be written to for the specified Write Node as defined in the configuration.
template
get_node_render_template(node
node)
Parameters & Return Value
-
node
node - the Write Node to query -
Returns:
template
- the render template this node is configured to use.
Example
>>> import sgtk
>>> eng = sgtk.platform.current_engine()
>>> app = eng.apps["tk-nuke-writenode"]
>>> nodes = app.get_write_nodes()
>>> app.get_node_render_template(nodes[0])
Get the template that determines where rendered images will be published to for the specified Write Node as defined in the configuration.
template
get_node_publish_template(node
node)
Parameters & Return Value
-
node
node - the Write Node to query -
Returns:
template
- the publish template this node is configured to use.
Example
>>> import sgtk
>>> eng = sgtk.platform.current_engine()
>>> app = eng.apps["tk-nuke-writenode"]
>>> nodes = app.get_write_nodes()
>>> app.get_node_publish_template(nodes[0])
Get the Published File Type to be used when Published files are created for images rendered by the specified Write node as defined in the configuration.
string
get_node_published_file_type(node
node)
Parameters & Return Value
-
node
node - the Write Node to query -
Returns:
string
- the Published File Type this node is configured to use
Example
>>> import sgtk
>>> eng = sgtk.platform.current_engine()
>>> app = eng.apps["tk-nuke-writenode"]
>>> nodes = app.get_write_nodes()
>>> app.get_node_published_file_type(nodes[0])
Get the path that the specified Write node will render images to.
string
get_node_render_path(node
node)
Parameters & Return Value
-
node
node - the Write Node to query -
Returns:
string
- the render path for this node
Example
>>> import sgtk
>>> eng = sgtk.platform.current_engine()
>>> a = eng.apps["tk-nuke-writenode"]
>>> nodes = app.get_write_nodes()
>>> app.get_node_render_path(nodes[0])
Generate a thumbnail for the specified Write Node. This will render a frame from the middle of the sequence with a maximum size of 800x800px to a temp file (.png). It is the responsibility of the caller to clean up this file when it is no longer needed.
string
generate_node_thumbnail(node
node)
Parameters & Return Value
-
node
node - the Write Node to query -
Returns:
string
- the path to the rendered thumbnail image on disk
Example
>>> import sgtk
>>> eng = sgtk.platform.current_engine()
>>> a = eng.apps["tk-nuke-writenode"]
>>> nodes = app.get_write_nodes()
>>> app.generate_node_thumbnail(nodes[0])
Reset the render path for the specified Write Node to match the current script.
None
reset_node_render_path(node
node)
Parameters & Return Value
-
node
node - the Write Node to query -
Returns:
None
- no value is returned
Example
>>> import sgtk
>>> eng = sgtk.platform.current_engine()
>>> a = eng.apps["tk-nuke-writenode"]
>>> nodes = app.get_write_nodes()
>>> app.reset_node_render_path(nodes[0])
Determine if the render path for the specified Write node is locked or not.
bool
is_node_render_path_locked(node
node)
Parameters & Return Value
-
node
node - the Write Node to query -
Returns:
bool
- True if the render path is locked, otherwise False
Example
>>> import sgtk
>>> eng = sgtk.platform.current_engine()
>>> a = eng.apps["tk-nuke-writenode"]
>>> nodes = app.get_write_nodes()
>>> app.is_node_render_path_locked(nodes[0])