Adverti horiz upsell
Nuke and Tcl - basics I
Nuke and Tcl - basics I
rueter, added 2006-05-18 16:50:16 UTC 32,583 views  Rating:
(0 ratings)
Page 4 of 4

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]}

click for larger version

changing the node colour for all selected nodes

foreach cur_node [selected_nodes] {knob $cur_node.tile_color 3}

click for larger version

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:


foreach cur_node [selected_nodes] {knob $cur_node.size 10}

click for larger version