indeed. that is the difference between Oliver's and my replies.

>>This code is executed constantly, so be very careful to put most of your code in conditionals with the relevant knob name, and keep it simple. >>Otherwise your scripts can really grind to a halt!

Yup, which is why I always try to do the conditional statements at the very top and try to bail out at the first possible moment.
You definitely want to be extra diligent with your code's efficiency if used as a global callback.



On 3/16/14, 10:52 AM, Jed Smith wrote:
It is also worth mentioning that knobChanged callback code can be specified in the menu.py file, applying to an entire node class, or knobChanged code can be stored and run in specific nodes only.

To store knobChanged code in a specific node, you can store the code to a special hidden knob called "knobChanged". This code will the be executed anytime you change anything on the node. 

For example, if you have a noOp node with a dropdown menu specifying colors, like this: 
NoOp {
 name NodeColor
 addUserKnob {20 NodeColor}
 addUserKnob {4 node_color t "Set Node Color" M {red green blue yellow}}
}

And you write some code to change the color of the node depending on the dropdown value, you can set the value of the knobChanged knob on that node if you select the node and execute this code:

Be careful with knobChanged knobs in nodes though. This code is executed constantly, so be very careful to put most of your code in conditionals with the relevant knob name, and keep it simple. Otherwise your scripts can really grind to a halt!

Hope that helps!

On Saturday, 2014-03-15 at 2:12p, Bruno-Pierre Jobin wrote:

Awesome! Thanks guys I'll have a look at this!


On Sat, Mar 15, 2014 at 5:03 PM, Frank Rueter|OHUfx <fr...@ohufx.com> wrote:

Here is something to get you started:

http://pastebin.com/2SbLf5PH

This adds a callback for nodes of class "NoOp", which you will have to change to react to your gizmo class or whatever other node you want this to work with.


Have a look and see if it makes sense.

Cheers,
frank



On 3/16/14, 8:37 AM, Bruno-Pierre Jobin wrote:
Hello Nukers,

I'm trying to find a way to change the color of a node (title_color) which would be driven by cascading pulldown choice menu. For example, if the first item is chosen, the node would be yellow and if the second one is chosen, it would turn blue.

I found this thread in the mailing list archive but I can't figure out where to paste that code...

https://www.mail-archive.com/nuke-users@support.thefoundry.co.uk/msg03405.html

I'm very new to python so please give a lot of details. 

Thanks!
--
Bruno-Pierre Jobin





_______________________________________________
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



--
Bruno-Pierre Jobin
www.bpjobin.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

Reply via email to