Works on: Nuke Versions:4.x Readership Level:Basic Owner:rueter Author Name: frank rueter
Looping
One of the most useful
things when using tcl in Nuke is the looping functionality. There are several ways to
create loops in tcl but the "foreach" method is probably the most
useful and easiest one at first so let's stick with that one for now.
syntax:
foreach variable list {}
this will loop through all elements in a list (i.e. list of nodes).
each time it loops the variable will hold the current item in the list.
examples:
this line reads the name of all selected nodes and prints them to the shell foreach cur_node
[selected_nodes] {puts [knob $cur_node.name]}
changing the node colour for all selected nodes foreach cur_node
[selected_nodes] {knob $cur_node.tile_color 3}
the following line will change the knob called "size" for all selected
nodes. In this case you will have to make sure that you only have nodes
selected that have that knob, otherwise this will produce an error: