Houdini 18.0 Nodes TOP nodes

Python Mapper TOP node

Maps work items using a Python script

On this page

This node can be used to write custom mapper logic using the Python API.

For use cases that can expressed as a single line Python or HScript expression, the Map by Expression is a simpler alternative.

Parameters

Save to Python Script

Saves the callbacks defined on this node to a Python script, which can be imported and registered with PDG. The parameter template associated with the node is also saved and embedded into the Python script. After saving the script is automatically imported and the node type is made available in the TAB menu.

Save to Digital Asset

Saves the callbacks defined on this node to a standalone Houdini Digital asset. The callbacks are stored inside the .hda itself and are registered with PDG as an embedded PDG node type.

Use Dynamic Mapping

By default, a mapper will establish dependencies between upstream static work items and downstream static work items. When this toggle is enabled, a second mapping pass will be done between any dynamic items above the mapper and static items below the mapper.

The dynamic items will be prefiltered based on the static mapping defined by the node, such that only dynamic items that descend from the selected static items will be considered.

onMapStatic Callback

This script is run in order to map upstream static items to downstream static items. It is always run once during the static cook step.

Several variables are available in the script:

self

Refers to the underlying PDG node associated with the TOP node. Note that this is different than TOP node itself, which is a standard Houdini operator.

Spare parameters added to the TOP node’s parameter interface will automatically be added to the PDG node.

upstream_items

The list of upstream static work items - these are the items that can be added as dependencies on the downstream items.

downstream_items

The list of downstream static work items - these are the items below the mapper that will be made to depend on some of the upstream static items.

dependency_holder

The object used to construct dependencies. For example, to add a dependency between the first upstream item and downstream item, one could write dependency_holder.addDepdendency(upstream_items[0], downstream_items[0]). The order the dependent/dependency are specified does not matter, as PDG will be able to determine which is which on its own.

onMapDynamic Callback

This script is run in order to map upstream dynamic items to downstream static items. It is run multiple times during the cook when dynamic work items are generated about the mapper node.

The dynamic work items passed in are pre-filtered by the results of the onMapStatic script, such that only dynamic items that descend from the static items selected in that script will be considered.

Several variables are available in the script:

self

Refers to the underlying PDG node associated with the TOP node. Note that this is different than TOP node itself, which is a standard Houdini operator.

Spare parameters added to the TOP node’s parameter interface will automatically be added to the PDG node.

upstream_items

The list of upstream dynamic work items - these are the items that can be added as dependencies on the downstream items.

downstream_items

The list of downstream static work items - these are the items below the mapper that will be made to depend on some of the upstream dynamic items.

dependency_holder

The object used to construct dependencies. For example, to add a dependency between the first upstream item and downstream item, one could write dependency_holder.addDepdendency(upstream_items[0], downstream_items[0]). The order the dependent/dependency are specified does not matter, as PDG will be able to determine which is which on its own.

Examples

example_top_pythonmapper Example for Python Mapper TOP node

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

See also

TOP nodes