Q100461: How to render Nuke scripts with the Frame Server using Python

Follow

SUMMARY

This article describes how you can render Nuke scripts using the Frame Server via Python.


MORE INFORMATION

In Nuke or Nuke Studio, renders can be executed using a couple of different methods, such as locally in the GUI, using a terminal session of Nuke or by using the Frame Server. 

The Frame Server allows Nuke to reduce render times by using multiple Nuke processes to distribute the work, either on the local machine, or on other machines on the network. More information about the Frame Server can be found here:

Rendering Using the Frame Server 

As of Nuke 11.0v1, Nuke scripts can be rendered on the Frame Server from the Nuke GUI, by checking the Render using frame server option in the Render dialog, as seen below: 

This will add the render job to the Background Renders queue, and start rendering it when there are Nuke processes available. 

To render Nuke scripts via Python using the Frame Server, there are two commands which can be used depending on what needs to be rendered:

from hiero.ui.nuke_bridge import FnNsFrameServer

#Queue background render of all the frames for a script
FnNsFrameServer.renderScript("C:/temp/test.nk")

#Queue background render of a range of frames for a script
FnNsFrameServer.renderFrames("C:/temp/test.nk", "1-10", "Write1", ["main"])

These commands require the Nuke script to be saved in order for the Frame Server to be able to render it. The commands could be combined with the nuke.scriptSaveAs() command in order to save out a temporary version of the script that can be rendered, to prevent the script accidentally being updated during the render. 

They can then be run in a custom menu/Python function or directly in the Script Editor, depending on the pipeline requirements. 

The renderScript() function renders all views for all Write nodes for the frames in the Nuke script called in the function. 

Whereas the renderFrames() function only renders the specified frames for the listed Write nodes and the defined Views in the script.

    We're sorry to hear that

    Please tell us why