Adverti horiz upsell
Nuke and Tcl - basics II
Nuke and Tcl - basics II
rueter, updated 2006-05-22 09:35:19 UTC 19,392 views  Rating:
(0 ratings)
Page 1 of 1

Nuke and Tcl - basics II

Writing your own tcl procedure

If you want to tie your tcl code into Nuke's UI you should put it into an extra tcl procedure and store that in your plugin path to make sure Nuke has access to it. Here is how you do it:

To write a tcl procedure you use the "proc" syntax.



this proc will return the number of nodes that are either selected or the overall number of nodes in the current script depending on which argument is used when it's called:

proc howManyNodes {selected} {
if {$selected == 1} {
set nodeCount [llength [selected_nodes]]
set outputText "$nodeCount nodes are currently selected"
} else {
set nodeCount [llength [nodes]]
set outputText "there are $nodeCount nodes in the script"
return $outputText

Using a text editor of your choice you can save the above code and call the file "howManyNodes.tcl" (it's important that the file name is the same as the procedure name). Make sure you save the file into a directory that is part of Nuke's plugin paths (see the page 136/137 in the user guide)

Once the tcl proc is savely tucked away you can edit your menu.tcl to add a menu item for it like this:

menu "My stuff/count nodes/selected" {howManyNodes 1}
menu "My stuff/count nodes/all" {howManyNodes 0}

After restarting Nuke you should see a new menu called "My stuff" which should look something like this:

For more informaion on how to use the menu.tcl to add hotkeys, menus etc. check out pages 138/139 in the user guide.


Please sign up or sign in to post a comment.