Skip to content

Instantly share code, notes, and snippets.

@greenvfx
Last active October 18, 2024 05:17
Show Gist options
  • Save greenvfx/8eb1ae0c42b56efcae0abe631022258d to your computer and use it in GitHub Desktop.
Save greenvfx/8eb1ae0c42b56efcae0abe631022258d to your computer and use it in GitHub Desktop.
single and multiline python expression in Nuke
#multiline py nuke's expression
b = nuke.nodes.Blur()
kb = b.knob('size')
multiline_python_expr = '''
[python -execlocal {
def myFunction(x):
return x*2
t = nuke.frame()
x = myFunction(t)
ret = x
}]'''
kb.setExpression( multiline_python_expr )
b.knob('label').setValue('multiline')
#single line py nuke's expression
b = nuke.nodes.Blur()
kb = b.knob('size')
singleline_py_expr = """ [python nuke.frame()/10 ]"""
kb.setExpression( singleline_py_expr )
b.knob('label').setValue('single line')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment