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:
foreach cur_node [selected_nodes] {knob $cur_node.size 10}

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:
foreach cur_node [selected_nodes] {knob $cur_node.size 10}

Author: rueter
Submitted: 2006-05-18 16:25:03 UTC
Tags:
Software: Nuke
Views: 32,651
Related Items
-
I-Mac 3D Model
$30.00 (USD) -
Quick and dirty medium/low res 45. Smith and Wesson handgun 3D Model
$25.00 (USD) -
Quill pen and ink bottle 3D Model
$20.00 (USD) -
Tire and Rim 3D Model
$9.00 (USD) -
Dinning chair and table 3D Model
$20.00 (USD) -
CHLBR Batch Render plugin for nuke 8.x for Nuke 1.0.0 (nuke plugin)
$40.00 (USD) -
Bath and Shower Set 3D Model
$40.00 (USD) -
Shield and sword 3D Model
$60.00 (USD) -
Entertainment System and Room Environment 3D Model
$49.99 (USD)








