oooh, that is tasty.

ok, so Ivan, a while back I really needed a way to color code switches so I
could see them clearly from "orbit" a bit better.  most of the ones that
were rigged up for this particular problem were simple 2 input switches, so
it was immensely helpful if I could just get them to simply be green if the
"which" = 0 or red if the which = 1.

I ended up making a little python script that went in and did the coloring
for me, but it would have been much more nicely implemented as a knobchanged
callback so I wouldn't have to manually update the script if I changed a
switch.

thanks for planting the seed, I'm sure I'll find a use for how you
constructed this 3 channel example soon.

but to apply this to something like a switch...  hmmm...   i'm a little
unsure about how to link the tile color to "which" values of 0 and 1.
and, other than your 3 color syntax - I wonder what the syntax would be if I
just wanted to use those hex color codes - green being 0xff00ff and red is
0xff0000ff.

I suppose an 'if then else' sort of thing might do the job.  what would be
really cool is if it would change to random colors for values above 1, like
if I had a 4 input switch if it would turn purple or something.

can anyone think of an example where they had some code that generated
random (but repeatable) colors?

even if it was just a cycle of 6 really bold colors that would repeat so
that a value of 6 and 12 are alike...  something like that would be really
cool to see how it's done, and I know I could find a use for it.  I can't
quite wrap my head around how you'd do this...  some sort of lookup table or
curve or something.

that seems like it would be helpful for another thing I was trying to do,
which is color rotoshapes a different color each time they are created.

anyway, if anyone has any idea on how to approach that sort of thing, much
appreciated!

On Mon, Jul 11, 2011 at 9:52 AM, Ron Ganbar <[email protected]> wrote:

> That's a really good tip. Cheers!
>
>
>
> Ron Ganbar
> email: [email protected]
> 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 <[email protected]> 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 <[email protected]> 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: [email protected]
>>> 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 <[email protected]> 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 <[email protected]> 
>>>> <[email protected]> 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 <[email protected]> 
>>>> <[email protected]> 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 <[email protected]> 
>>>> <[email protected]> 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 [email protected], 
>>>> http://forums.thefoundry.co.uk/http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>>
>>>>
>>>> _______________________________________________
>>>> Nuke-users mailing [email protected], 
>>>> 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
>>>> [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

Reply via email to