tcl functions called by Nuke

The following is a list of tcl functions that the user can provide for Nuke as callbacks. More...

Functions

 OnCreate
 Run when a node is created by the user.
 filename_fix filename
 Mangles filenames to make them portable or customize them to a site.
 unknown command argv1 argv2 argv3...
 Add a file extension alias.
 autolabel
 Returns text to draw on a node.

Detailed Description

The following is a list of tcl functions that the user can provide for Nuke as callbacks.

On some occasions, Nuke checks for the existence of a tcl script with any of the names below. If such a procedure exist, Nuke will call this procedure from within the current context.


Function Documentation

OnCreate (

Run when a node is created by the user.

The function "OnCreate", if it exists, is run when a node is created with a tcl command with a -new switch or with no arguments. This is normally done by menu items that create new nodes. It is run in the context of the new node, ie "this" points at the new node.

This can be used to preset the node or add extra user knobs to it. Note that most presets can be done by using knob_default instead. Also if you add a huge amount, it may be better to instead define a gizmo to do the same thing, and change the menu items to call your gizmo instead. This will allow the gizmo definition to change, while the results of OnCreate are saved in the script.

filename_fix ( filename 

Mangles filenames to make them portable or customize them to a site.

The function "filename_fix name", if it exists, is used to mangle filenames in Nuke scripts into the names passed to the operating system. This is mostly useful for getting around operating system differences, for instance we use it to add the correct drive letters to the start of pathnames by defining it this way when $WIN32 is true:

   proc filename_fix {arg} {
    if {[string range $arg 0 4]=="/job/"} {
      global env
      return "Z:$arg"
    } else {
      return $arg
    }
   }

You could also mangle names in the opposite direction (stripping drive letters on Unix) or use this on all platforms to perform substitutions based on environment variables.

If you don't define filename_fix, a builtin version is used. It does nothing on Windows, and removes a leading drive letter and colon on Unix.

Not all filenames used by Nuke are passed through this! However script, image file, and plugin names are.

unknown ( command argv1 argv2  argv3...

Add a file extension alias.

  • from: the alias
  • to: the file extension to map it to

Map one file extension to another, for finding readers and writers.

Called when an unknown tcl command is executed.

This function is called with the name and arguments for any unknown tcl command. The built-in version will attempt to locate a plugin by the same name as the command, load it, and then re-run the command.

You may be able to redefine this to really change Nuke's behavior...

See also:
load, plugins
autolabel (

Returns text to draw on a node.

This command is called automatically to generate the text to draw on a node. You can change everything, including how or whether the node's name is displayed. By imbedding @-commands you can set the font, color, justification, make super/sub scripts, and insert images. You can also set other knobs, such as the color and icons, to control the appearance of a node.

The command is executed in the context of the node and should return a string. If it returns an empty string (or error) the node's name is used, if you really want the node blank you should return a space.

Any error message is printed to stdout, which may be hard to see. If your autolabel does not appear to be working, try executing "in Node {autolabel}" as a tcl command to test it and see any errors. Also, Nuke stores the result and only updates it when it thinks it has to. If values stored on the node have not changed it does not call this.