push a Nuke button in a shell script?


#1

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”

http://sht.tl/b90

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.


#2

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)


#3

thanks - I’ll look into that.


#4

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


#5

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


#6

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

g = nuke.nodes.GenerateLUT()
g['file'].setValue('/path/you/want/to/write/your/lut/to/lutFile.cube')
g['file_type'].setValue('.cube')
g['bitdepth_id'].setValue('16 bit')
g['generate'].execute()

#7

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.


#8

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['file'].setValue('/Users/beige/Desktop/lutFile.cube')
g['file_type'].setValue('.cube')
g['bitdepth_id'].setValue('16 bit')
g['generate'].execute()

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.


#9

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.