hi Adam,

you only need one knobChanged knob per node.
the knobChanged knob is hidden by default but it is just like the
beforeRender or afterRender knob in the write nodes - you can paste python
scripts there which are executed in their special cases.
the knobChanged is executed every time anything is changed on the node.
(position / knob values / set selected / ....)

but if you want to limit the execution for every change of the node you can
use nuke.thisKnob().name() inside of your knobChanged python script so that
the script only does stuff when a specific knob is changed.

for example on a grade node some  knobChanged script could look like that:

thisNode = nuke.thisNode()
thisKnob = nuke.thisKnob()

if thisKnob.name() == "multiply":
    nuke.message("changed the multiply Knob!")


but how to assign it?

# I would put that script in a multiline string (3 times " at the beginning
and end )

#________START________________

myGradeKnobChangedString = """
thisNode = nuke.thisNode()
thisKnob = nuke.thisKnob()

if thisKnob.name() == "multiply":
    nuke.message("changed the multiply Knob!")
"""

#  and then I would would add this by a simple script to the selected grade
node:

nuke.selectedNode()["knobChanged"].setValue(myGradeKnobChangedString)

#________END________________

now everytime the multiply knob is changed the message pops up.

you can add as many knobname if-conditions as you like.

was this helpful?

cheers,
Vincent


2017-02-12 9:53 GMT+01:00 adam jones <adam....@mac.com>:

> Dear All
>
> can you only have one knobChanged per node?
>
> Can do it via a couple of NoOp nodes inside the group for each knobChanged
> but once again the group GUI does not update
>
> Kind Regards
> -adam
>
>
>
> On 12 Feb 2017, at 10:49 AM, adam jones <adam....@mac.com> wrote:
>
> Dear Vincent
>
> It does in a way, I was airing towards that as I was getting this error in
> the console
>
> 'TypeError: must be bool, not str’
>
> I also miss spoke in my original email it is a pull down driving the
> switch node that is driving  the checkbox. does the switch node not give
> out indexed numbers
>
> I think from the example you gave me in cut and paste I can work it out
> from there, maybe
>
> Kind Regards
> -adam
>
>
>
> On 12 Feb 2017, at 8:31 AM, Vincent Langer <m...@vincentlanger.com> wrote:
>
> maybe you could just paste your group here to make clearer what you are
> after.
>
> with python pull down choices return the string not the index number of
> the current choice.
> but the knob has the function .values() which returns a list of each
> option in the pulldown.
>
> does this help you?
>
> cheers,
> VIncent
>
> 2017-02-11 22:24 GMT+01:00 Vincent Langer <m...@vincentlanger.com>:
>
>> I am not sure if that is what you are looking for:
>>
>> set cut_paste_input [stack 0]
>> version 10.0 v4
>> push $cut_paste_input
>> Group {
>>  name Group1
>>  knobChanged "\nthis = nuke.thisNode()\nk = nuke.thisKnob()\n\nif k.name()
>> == \"UseRGBKnob\":\n    if k.value() == \"Yes\":\n
>> this\[\"RGB\"].setEnabled(True)\n    else:\n
>> this\[\"RGB\"].setEnabled(False)\n"
>>  selected true
>>  xpos 168
>>  ypos -18
>>  addUserKnob {20 User}
>>  addUserKnob {4 UseRGBKnob M {Yes No}}
>>  addUserKnob {18 RGB}
>>  RGB {0 0 0}
>>  addUserKnob {6 RGB_panelDropped l "panel dropped state" -STARTLINE
>> +HIDDEN}
>> }
>>  Input {
>>   inputs 0
>>   name Input1
>>   xpos 123
>>   ypos -67
>>  }
>>  NoOp {
>>   name NoOp1
>>   xpos 123
>>   ypos -27
>>  }
>>  Output {
>>   name Output1
>>   xpos 123
>>   ypos 73
>>  }
>> end_group
>>
>>
>> 2017-02-11 8:41 GMT+01:00 adam jones <adam....@mac.com>:
>>
>>> Dear all
>>>
>>> So I really tried to work this out myself but I am stuck
>>>
>>> I have set up a RGB knob and a check box to enable and disable it using
>>>
>>> this snippet (frank posted it years back, thank you)
>>>
>>> node = nuke.toNode('NoOp1')
>>> code = '''nuke.thisNode()['pickDS'].setEnabled(nuke.thisNode()['ena
>>> blePick'].value())'''
>>> node['knobChanged'].setValue(code)
>>>
>>> this works great,
>>>
>>> interesting thing could not create it inside a group, created it outside
>>> of the group and cut and pasted into the group and all good
>>>
>>> then I placed and expression on the check box to connect it to a pull
>>> down choice
>>>
>>> switch1 > 3 ? 1 : 0 this switch node is connected to a pulldown choice
>>> on the groups GUI
>>>
>>> it first appeared as though it was not working, the checkBox would
>>> update but nothing would (RGB) knob would not update its state in the GUI
>>> of the group unless I closed and re opened the NoOp1 node inside the group.
>>>
>>> and it does what is expected, so I guess the question is how do I get
>>> the interface to update with out doing what I explained
>>>
>>> Does that make sense
>>>
>>> Kind Regards
>>> -adam_______________________________________________
>>> Nuke-users mailing list
>>> Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>
>>
>>
>>
>> --
>> Vincent Langer
>> Uhlandstr. 29
>> 71634 Ludwigsburg
>> +49 176 965 177 61 <+49%20176%2096517761>
>> www.vincentlanger.com
>>
>
>
>
> --
> Vincent Langer
> Uhlandstr. 29
> 71634 Ludwigsburg
> +49 176 965 177 61 <+49%20176%2096517761>
> www.vincentlanger.com
> _______________________________________________
> Nuke-users mailing list
> Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>
>
> _______________________________________________
> Nuke-users mailing list
> Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>
>
>
> _______________________________________________
> Nuke-users mailing list
> Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>



-- 
Vincent Langer
Uhlandstr. 29
71634 Ludwigsburg
+49 176 965 177 61
www.vincentlanger.com
_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

Reply via email to