Tuesday, June 5, 2012

How to check if knob exist in selected Node?

if node[knobname] <-- this command will fail when the knob doesn't exist :
e.g :
if node['translate'] : XXX
#NameError: knob translate does not exist


The trick is using .knob() :
if node.knob(knobname)
e.g :
if node.knob('translate') : XXX
Nuke won't spit out error message, it will just simply pass/ignore the 'XXX' when knob 'translate' doesn't exist.

2 comments: