Get list of values from nuke.EvalString_Knob?

Viewed 375

I'm trying to work with a custom group node that has a bunch of EvalString_Knobs and I need to get a list of items in them but when I try using node['knobName'].values()

I get an attribute error as values isn't an attirbute of EvalString_Knob.

Anyone have a way to get the values of EvalString_Knob?

Thanks.

2 Answers

Let's create two EvalString_Knob inside a new tab:

import nuke

write = nuke.createNode('Write', inpanel=False)
tab = nuke.Tab_Knob("Parameters")
write.addKnob(tab)
write.addKnob(nuke.EvalString_Knob('prefix','Prefix','render'))
write.addKnob(nuke.EvalString_Knob('suffix','Suffix','7'))

In UI it looks like that:

enter image description here

For listing all the dictionary's knobs of a Write node use the following command:

nuke.toNode("Write1").knobs().keys()

To get a value of any known knob use this command:

nuke.toNode("Write1").knob('prefix').getValue()

To list all the properties with their corresponding values use this approach:

nuke.selectedNode().writeKnobs()

P.S.

TabKnobs have no names to reach them. Only empty strings.

You can use

node['knobName'].getValue() to get a string returned from an EvalString_Knob, node['knobName'].values() to get a list returned from an Enumeration_Knob,

and you can use node['knobName'].Class() to find out what is the type of the knob.

Related