That's a really good tip. Cheers!

Ron Ganbar
email: ron...@gmail.com
tel: +44 (0)7968 007 309 [UK]
     +972 (0)54 255 9765 [Israel]
url: http://ronganbar.wordpress.com/



On 11 July 2011 17:45, Ivan Busquets <ivanbusqu...@gmail.com> wrote:

> Hi Ron,
>
> You can bake knobChanged callbacks (or other callbacks like onCreate) into
> a node by filling its hidden "knobChanged" knob with your desired code as a
> string.
> For example:
>
> n = nuke.createNode('Blur')
>
> n['knobChanged'].setValue('if nuke.thisKnob().name() == "size": print "size
> knob changed"')
>
>
> If you need your callback code to have multiple lines, just triple-quote
> the string:
>
> n['knobChanged'].setValue("""
> # do
> # smart
> # stuff
> # here
> """)
>
> Cheers,
> Ivan
>
>
> On Mon, Jul 11, 2011 at 9:26 AM, Ron Ganbar <ron...@gmail.com> wrote:
>
>> Hi Ivan,
>> I had to look at the actual .nk file in a text editor to see what you made
>> there. How can I see and change the python script in the gui itself? How did
>> you add it to the node?
>>
>> Thanks,
>> Ron Ganbar
>> email: ron...@gmail.com
>> tel: +44 (0)7968 007 309 [UK]
>>      +972 (0)54 255 9765 [Israel]
>> url: http://ronganbar.wordpress.com/
>>
>>
>>
>> On 11 July 2011 17:06, David Schnee <dav...@tippett.com> wrote:
>>
>>> **
>>> Thank you Ivan, this is great!
>>>
>>> Cheers,
>>> -Schnee
>>>
>>>
>>> On 07/08/2011 11:49 PM, Ivan Busquets wrote:
>>>
>>> Ok, something's going definitely wrong when I copy-paste this. Script
>>> attached instead.
>>>
>>> Sorry about that.
>>>
>>>
>>> On Fri, Jul 8, 2011 at 11:40 PM, Ivan Busquets <ivanbusqu...@gmail.com> 
>>> <ivanbusqu...@gmail.com> wrote:
>>>
>>>
>>>  Hmm, something went funny with the formatting after copy/pasting. Here
>>> it is again.
>>>
>>>
>>> set cut_paste_input [stack 0]
>>> version 6.2 v3
>>> push $cut_paste_input
>>> NoOp {
>>>  name NoOp1
>>>  knobChanged "\nn = nuke.thisNode()\nk = nuke.thisKnob()\nif k.name()
>>> in \['red', 'green', 'blue']:\n
>>> nuke.thisNode()\['tile_color'].setValue(int('%02x%02x%02x%02x' %
>>> (n\['red'].value()*255,n\['green'].value()*255,n\['blue'].value()*255,1),16))\n\n\n"
>>>  tile_color 0xff0001
>>>  selected true
>>>  xpos -299
>>>  ypos -47
>>>  addUserKnob {20 User}
>>>  addUserKnob {6 red +STARTLINE}
>>>  addUserKnob {6 green +STARTLINE}
>>>  green true
>>>  addUserKnob {6 blue +STARTLINE}
>>> }
>>>
>>>
>>>
>>> On Fri, Jul 8, 2011 at 11:37 PM, Ivan Busquets <ivanbusqu...@gmail.com> 
>>> <ivanbusqu...@gmail.com> wrote:
>>>
>>>
>>>  That's a fun idea :)
>>> Yes you can, using a knobChanged callback that fires when any of your 
>>> "red", "green" or "blue" knobs are changed.
>>> The trickiest bit is probably to set the right value for the tile_color 
>>> knob based on your rgb values, since tile_color uses values packed in a 
>>> rather awkward way.
>>> But here, have a look and see if that does what you want.
>>>
>>> set cut_paste_input [stack 0] version 6.2 v3 push $cut_paste_input NoOp { 
>>> name NoOp1 knobChanged "\nn = nuke.thisNode()\nk = nuke.thisKnob()\nif 
>>> k.name() in \['red', 'green', 'blue']:\n 
>>> nuke.thisNode()\['tile_color'].setValue(int('%02x%02x%02x%02x' % 
>>> (n\['red'].value()*255,n\['green'].value()*255,n\['blue'].value()*255,1),16))\n\n\n"
>>>  tile_color 0xff0001 selected true xpos -299 ypos -17 addUserKnob {20 User} 
>>> addUserKnob {6 red +STARTLINE} addUserKnob {6 green +STARTLINE} green true 
>>> addUserKnob {6 blue +STARTLINE} }
>>>
>>> Cheers,
>>> Ivan
>>> On Fri, Jul 8, 2011 at 10:46 AM, David Schnee <dav...@tippett.com> 
>>> <dav...@tippett.com> wrote:
>>>
>>>
>>>  Does anyone know if there is a way to dynamically link/change tile_color 
>>> with user knobs?  Say I have a gizmo with a check box for red,green, and 
>>> blue.  If only the red is checked, I want the tile_color to be red, if red 
>>> and green are checked, yellow, just blue, blue, and so on.  Is this 
>>> possible?
>>>
>>> Cheers,
>>> -Schnee
>>>
>>> --
>>>
>>> \/ davids / comp \/ 177
>>> /\ tippettstudio /\ b d
>>>
>>> _______________________________________________
>>> Nuke-users mailing listnuke-us...@support.thefoundry.co.uk, 
>>> http://forums.thefoundry.co.uk/http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>
>>>
>>> _______________________________________________
>>> Nuke-users mailing listnuke-us...@support.thefoundry.co.uk, 
>>> http://forums.thefoundry.co.uk/http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>
>>>
>>>
>>> --
>>>
>>> \/ davids / comp \/ 177
>>> /\ tippettstudio /\ b d
>>>
>>>
>>> _______________________________________________
>>> 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
>
_______________________________________________
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