Here's a the quick script. Very simular to something Diego posted some
months ago. It works well, but for some reason it doesn't update if the
slider is animated, only if you change the values by hand. Is there a way
around this?
def mergeColor():
n = nuke.thisNode()
k = nuke.thisKnob()
if k.name() == "mix":
v = k.value()
green = v
red = 1 - int(v)
r = red
g = green
b = 0
hexColour = int('%02x%02x%02x%02x' % (r*255,g*255,b*255,1),16)
n["tile_color"].setValue(hexColour)
nuke.addKnobChanged(mergeColor, nodeClass="Merge2")
2012/1/6 J Bills <[email protected]>
> I'd tried that but it seems to only evaluate initially and then not update
> when the switch node switches. must be something about it being a
> backdrop...
>
>
> On Thu, Jan 5, 2012 at 3:55 PM, Diogo Girondi <[email protected]>wrote:
>
>> In theory if I understand you correctly you could just replace the
>> "this.tile_color" for "BackdropNode1.tile_color" to have the Switch node
>> driving the BackdropNode tile color. The problem is that you will have to
>> explicitly state the backdrop's node name so it might not be that useful.
>>
>> So python callbacks might end up being a better option for you.
>>
>> But I'll see if I can think of a better approach to this using TCL in
>> labels.
>>
>>
>>
>> cheers,
>> diogo
>>
>>
>>
>>
>> On Thu, Jan 5, 2012 at 5:47 PM, J Bills <[email protected]> wrote:
>>
>>> diogo, this is awesome. I'll use this all the time.
>>>
>>> so say your code here going in a switch node and were changing it from
>>> red to green like this... do you know what the syntax would be to link a
>>> backdrop node to the switch so the whole background changes red or green
>>> along with it?
>>>
>>> i'm trying to figure out a way to do it but I can't quite seem to link
>>> them up. i might be able to do it with some sort of knobchanged callback
>>> but I'd love it if there were some way to evaluate the tile_color of
>>> another node directly in your tcl line, because it's nice and clean.
>>> callbacks are so very very dirty... :)
>>>
>>>
>>> On Tue, Jan 3, 2012 at 4:34 PM, Diogo Girondi <[email protected]>wrote:
>>>
>>>> Now that I'm in front of Nuke I realize that I've missed the brackets
>>>> on the return code in order to allow it to be evaluated by the label.
>>>>
>>>>
>>>> So here is the actual code:
>>>>
>>>>
>>>> [if {[value this.disable]=="false"} {return "[knob this.tile_color
>>>> 0xff000000]"} {return "[knob this.tile_color 0xff00ff]"}]
>>>>
>>>> Hope it helps.
>>>>
>>>>
>>>> cheers,
>>>> diogo
>>>>
>>>> On Wed, Dec 28, 2011 at 5:26 PM, Simon Björk
>>>> <[email protected]>wrote:
>>>>
>>>>> Thanks a lot for your help Diogo. I tried that code but couldn't
>>>>> figure out how to use it. I solved the problem with python callbacks (and
>>>>> with some code you posted a few moths ago).
>>>>>
>>>>>
>>>>> 2011/12/27 Diogo Girondi <[email protected]>
>>>>>
>>>>>> Ahhh!
>>>>>>
>>>>>> Well there is a simpler (less reliable) way that works and doesn't
>>>>>> take you the callback which is using a standard if then else in TCL using
>>>>>> the node's label.
>>>>>>
>>>>>> Pseudo code with missing everything (because I can't test this right
>>>>>> now and TCL is fading in my brain)
>>>>>>
>>>>>> [if {[value knob]==something} then {return "knob tile_color 1 0 0}
>>>>>> else {return "knob tile_color 0 1 0"}]
>>>>>>
>>>>>> Cheers,
>>>>>> Diogo
>>>>>>
>>>>>> On 27/12/2011, at 07:51, matt estela <[email protected]> wrote:
>>>>>>
>>>>>> heh, i just stumbled across the code, i didn't write it, nor do i
>>>>>> have nuke at home to test it. :)
>>>>>>
>>>>>>
>>>>>> On 27 December 2011 10:13, Simon Björk <[email protected]>wrote:
>>>>>>
>>>>>>> Yes, I'm talking of the actual color of the node. I have a script
>>>>>>> where I have a lot of elements fading in at different time and it would
>>>>>>> be
>>>>>>> very easy to visually see if they are enabled by just looking at the
>>>>>>> color
>>>>>>> of the nodes.
>>>>>>>
>>>>>>> Matt, the method in the link you posted doesn't seem to work,
>>>>>>> nothing happens when I change the value of the checkboxes.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> 2011/12/26 matt estela <[email protected]>
>>>>>>>
>>>>>>>> I think Simon was talking about the colour of the node, not the
>>>>>>>> result of the mix itself.
>>>>>>>>
>>>>>>>> This might be what your after:
>>>>>>>>
>>>>>>>> http://pastebin.com/4dyBTAnP
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On 27 December 2011 05:27, Diogo Girondi <[email protected]>wrote:
>>>>>>>>
>>>>>>>>> this.mix==1?0:1
>>>>>>>>> this.mix==1?1:0
>>>>>>>>>
>>>>>>>>> Just add the first line to the red channel and the second to the
>>>>>>>>> green channel. But if you need to "dissolve" between the values use:
>>>>>>>>>
>>>>>>>>> abs(-1+this.mix)
>>>>>>>>> this.mix
>>>>>>>>>
>>>>>>>>> For red and green respectively.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On 26/12/2011, at 13:06, Simon Björk <[email protected]>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Is there a way to add an expression to the color of a node? For
>>>>>>>>> example I have a node with a mix slider and want the color of the
>>>>>>>>> node to
>>>>>>>>> be green if the value is 1 and red if the value is 0. But I can't
>>>>>>>>> find a
>>>>>>>>> way to add an expression to this.
>>>>>>>>>
>>>>>>>>> --------------------------------
>>>>>>>>> Stiller Studios
>>>>>>>>> Lidingö/Sweden
>>>>>>>>>
>>>>>>>>> Simon Björk
>>>>>>>>> Stiller Studios
>>>>>>>>> +46 (0)8 555 23 560
>>>>>>>>> Ekholmsnäsvägen 40, S-181 41 Lidingö
>>>>>>>>> [email protected]
>>>>>>>>> www.stillerstudios.se
>>>>>>>>>
>>>>>>>>> find us:
>>>>>>>>> http://www.eniro.se/query?search_word=stiller+studios&geo_area=liding%F6&what=all
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Nuke-users mailing list
>>>>>>>>> [email protected],
>>>>>>>>> http://forums.thefoundry.co.uk/
>>>>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Nuke-users mailing list
>>>>>>>>> [email protected],
>>>>>>>>> http://forums.thefoundry.co.uk/
>>>>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Nuke-users mailing list
>>>>>>>> [email protected],
>>>>>>>> http://forums.thefoundry.co.uk/
>>>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> --------------------------------
>>>>>>> Stiller Studios
>>>>>>> Lidingö/Sweden
>>>>>>>
>>>>>>> Simon Björk
>>>>>>> Stiller Studios
>>>>>>> +46 (0)8 555 23 560
>>>>>>> Ekholmsnäsvägen 40, S-181 41 Lidingö
>>>>>>> [email protected]
>>>>>>> www.stillerstudios.se
>>>>>>>
>>>>>>> find us:
>>>>>>> http://www.eniro.se/query?search_word=stiller+studios&geo_area=liding%F6&what=all
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Nuke-users mailing list
>>>>>>> [email protected], http://forums.thefoundry.co.uk/
>>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Nuke-users mailing list
>>>>>> [email protected], http://forums.thefoundry.co.uk/
>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Nuke-users mailing list
>>>>>> [email protected], http://forums.thefoundry.co.uk/
>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> --------------------------------
>>>>> Stiller Studios
>>>>> Lidingö/Sweden
>>>>>
>>>>> Simon Björk
>>>>> Stiller Studios
>>>>> +46 (0)8 555 23 560
>>>>> Ekholmsnäsvägen 40, S-181 41 Lidingö
>>>>> [email protected]
>>>>> www.stillerstudios.se
>>>>>
>>>>> find us:
>>>>> http://www.eniro.se/query?search_word=stiller+studios&geo_area=liding%F6&what=all
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Nuke-users mailing list
>>>>> [email protected], http://forums.thefoundry.co.uk/
>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Nuke-users mailing list
>>>> [email protected], http://forums.thefoundry.co.uk/
>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>>
>>>
>>>
>>> _______________________________________________
>>> Nuke-users mailing list
>>> [email protected], http://forums.thefoundry.co.uk/
>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>
>>
>>
>> _______________________________________________
>> Nuke-users mailing list
>> [email protected], http://forums.thefoundry.co.uk/
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>
>
>
> _______________________________________________
> Nuke-users mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>
--
--------------------------------
Stiller Studios
Lidingö/Sweden
Simon Björk
Stiller Studios
+46 (0)8 555 23 560
Ekholmsnäsvägen 40, S-181 41 Lidingö
[email protected]
www.stillerstudios.se
find us:
http://www.eniro.se/query?search_word=stiller+studios&geo_area=liding%F6&what=all
_______________________________________________
Nuke-users mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users