Houdini 17.5 Nodes TOP nodes

Python Script TOP node

Creates work items that run a script

On this page

This node creates work items that run a Python script either in process or as a scheduled job. In-process scripts can access a larger amount of information about the PDG graph, as well as other objects and settings within the current Houdini session. If the script is run out of process it is limited to accessing the attributes of the work item it is associated with, and anything the script can import itself.

The node will always created exactly one work item per upstream item, with the Python Code field as the work to be done for that item. To generate custom work item configuration, the Python Processor node should be used instead.

TOP Attributes

script

string

The Python script that the work item will execute.

Parameters

Work Item Generation

Whether this node generates static or dynamic work items. You should generally leave this set to "Automatic" unless you know the node’s work items can be computed statically, or that they need to be generated dynamically.

Dynamic

This node always creates dynamic work items: it waits until the upstream work items are known, and generates new work items from the upstream work items.

Static

This node always creates static work items: it creates the number of work items it thinks it needs based on the parameters (and any upstream static items) before the network runs.

Automatic

If the input is static (a static processor, or a partitioner with only static inputs, or a mapper), this node generates static work items, otherwise it generates dynamic work items.

Evaluate In Process

Indicates whether or no the script should be run in the current Houdini process.

Copy Inputs to Outputs

When this option is enabled, the Python Script node will automatically copy input files to its output file list.

Python Bin

When running out of process, this parameter determines which Python executable to use to run the script.

Custom Python Bin

When Python Bin is set to Custom this parameter is evaluated to determine the path to the Python executable.

Python Arguments

Extra arguments passed to the Python executable itself to configure the behavior of the interpreter.

Script Arguments

Arguments passed to the Python script. These values are accessible in the script through sys.argv[1:].

Reset Python Path Variables

When this toggle is enabled the PYTHONHOME and PYTHONPATH variables defined by Houdini are reset in the external Python process. This is necessary when using a Python version that is incompatible with the one built into Houdini.

Python Code

The Python code that is run for each work item.

When running out of process, the code is saved to disk an executed using the specified Python interpreter. The script has access to the work_item variable which provides an API to access the name, index, frame and attributes of the work item associated with the script. Additionally, the intData, floatData and strData helper functions can be used to query attributes on the work item.

When running in-process the script is run using the Python interpreter embedded in Houdini. In addition to the work_item variable, the self and parent_item variables are also available. The former is a reference to the node that owns the work item, and the parent_item variable is a reference to the parent or None.

Examples

example_top_pythonscript Example for Python Script TOP node

This example demonstrates how to use the Python Script node in PDG/TOPs.

The following examples include this node.

example_top_downloadfile Example for Download File TOP node

This example demonstrates how to download a file using the downloadfile node.

example_top_environmentedit Example for Environment Edit TOP node

This example demonstrates how to modify the environment variables before spawning a child process.

example_top_genericcommandchain

This example demonstrates how to create generic command chains.

example_top_pythonscript Example for Python Script TOP node

This example demonstrates how to use the Python Script node in PDG/TOPs.

example_top_sendemail Example for Send Email TOP node

This example demonstrates how to use the send email top node to send a simple e-mail.

See also

TOP nodes