When you start nuke you can pass it a .py file and it will execute this file on startup
When issuing a command line render is it possible to feed it the startup py script along with the nuke script you want to render?
running nuke interactive:
running nuke command line render:
nuke8.0.exe -x nukeScript.nk
What I need is something like this, so nuke will launch in a shell import the python script then execute the nukescript
nuke8.0.exe PyScript.py -x nukeScript.nk
This does not work… it will launch an interactive session and import the PyScript.py then ignore -x and not open or render the nukeScript.nk file
Here is (a lot) more detail about my process…
I’ve begun building a python module to assist with my pipeline…
This consists of fetching information from a database, and handling write node outputs automatically based on the nuke script name.
This all works well inside an interactive session of nuke, I have a python script that sets env vars and launches nuke with a startup py script. This startupscript sets paths, and imports my module… and the important part my module imports the nuke module so I can get node information within the nuke script.
Launch nuke script sudo code::
os.environ["PROJECT_NAME"] = "blahBlahBlah" # Later scripts use this info to get data from the database os.system(nuke startupscript.py) # This launches nuke and makes it run startupscript.py when it opens
startupscript.py sudo code::
import sys import nuke sys.path.append("pipelinepath") # Add pipeline path (this is dynamic based on user machine) nuke.pluginAddPath("somePath") # Add paths for nuke to find scripts, gizmos etc.. import pipeline.nuke # Make my module available for use within nuke
pipeline.nuke.py sudo code::
import nuke # This module needs the nuke module to read nuke data def outputFromFilename() scriptName = nuke.root()['name'].getValue() # Get nuke script name output = pipelineFunction() # Run pipeline functions to determine output nuke.thisNode().knob("beforeRender").setValue('pipeline.nuke.makeOutputFolder()') # Make sure output directory exists before rendering since nuke is too stupid to make if for you. return output
So in the nuke script, the write node filename would be set to
All of this requires that my scripts can “import nuke” module
Adding the nuke/plugins path to sys.path allows me to import nuke… but it fails on the line
from _nuke import * within nuke/plugins/nuke/init.py
My modules live outside the nuke folder (network location), so they are version agnostic and don’t require every new user to install plugins / scripts into their local nuke folder… so i’m not interested in a solution involving copying scripts to local machines.
I know you can start python from within the nuke folder and import nuke that way, perhaps this is a solution but I get a license error when trying this (I only have an interactive license at the moment and don’t know how to trigger the use of an interactive license)
Thanks for reading
Any help is appreciated.