push a Nuke button in a shell script?


I’m making a template for generating .cube files and want to avoid using the GUI so I’m making a bash shell script. I have the part that filters the input to generate the scene but I can’t just render the scene to generate the cube file. I need to hit “Generate and Write LUT file”


Is there a way to do that from the command line? I don’t know if Nuke lets you do stuff like this. In Maya, I could do a MEL or Python pre-render script with the command line render app.


in command line mode you can use the -X flag to execute a node (if you want to render for example you write -X writeNodeName) or you can try to use the .execute() python command (but I have never done that trough command line)


thanks - I’ll look into that.


PyScript knobs have a .execute() method that can be called in terminal mode.


would you know what the python call is for Generate LUT? I have zero experience with scripting Nuke so I don’t know where to look for this stuff or feedback from GUI operations, if there is any


This will generate the node in your linked image (minus an identical path).

g = nuke.nodes.GenerateLUT()
g['bitdepth_id'].setValue('16 bit')


ok - so I understand how to execute that with -t in bash but how do I tell it where to look for the Read source that it needs for the input? I’m sorry if this seems obvious but I’m not familiar with Python.


ok - after reading a bit of the docs and wrapping my head around Python a bit, I figured it out:

import sys

r = nuke.nodes.Read(file = '/Volumes/HOME_RAID/STOCK/cube_3D_luts/template_files/test.tif')

g = nuke.nodes.GenerateLUT()
g.setInput( 0, r )
g['bitdepth_id'].setValue('16 bit')

Now I’ll just make the file into a variable sys.argv[1]. Thanks for the help. I’ll be putting an auto-3DLUT shell script up on Nukepedia soon.


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.