Houdini 21.0 Nodes Geometry nodes

Python Snippet geometry node

Runs a snippet of Python on geometry.

On this page

The Python Snippet SOP provides a general interface to run Python code on geometry.

The parameters of the python snippet are controlled by the Bindings tab.

Syntax

The script you write has kwargs object with all of the inputs and bound parameters available. It is expected to return a hou.Geometry of the output.

Similar to the OpenCL Snippets, the #bind syntax can be used to define the bound parameters in the code. These commands are considered comments in Python so are ignored by the evaluation, but are used by the “Create input and spare parameters” button to setup the signatures and bindings appropriately.

Warning

While Python can be easy to write, it is CPU-basd and intepreted, so for per-point operations VEX or OpenCL should be preferred.

Note

You likely do not need to manually edit the Signature or Bindings tabs if you are not doing something esoteric. They are often set up with the “Create inputs and spare parameters” button.

Note

Unlike the SOP Python Script node, this does not have any access to the currently evaluating node. This allows the cooking to be separated from the node network and act as a pure verb.

Parameters

Kernel

Python Code

Python code that takes kwargs dictionary containing the bound parameters and input geometry and returns a hou.Geometry of the result.

Options

Maintain State

When enabled, the underlying Python interpreter will not be cleared between cooks. This may give some performance gains, but can also lead to unexpected behaviour. It is generally recommended to leave this disabled.

Bindings

Bindings

Each parameter is a fixed constant value evaluated before the python code is executed. These are provided in the kwargs to the python snippet to allow the python code to run independently of any particular node.

Bind#

Name

The name of the parameter. This is the value used in the kwargs dictionary.

Type

The type of parameter to create and bind.

Integer

A constant integer value, allowing you to bind channel references and expressions that are pre-computed.

Float

A constant float value.

Vector2

A constant tuple of two floats.

Vector

A constant tuple of three floatsa.

Vector4

A constant tuple of four floats.

Ramp

A scalar or color ramp. This becomes a hou.Ramp object.

String

A constant string value.

Data Type

The type of ramp to bind

Float

A scalar ramp.

Vector

A color ramp.

Ramp

The scalar ramp values.

Ramp

The color ramp values.

Value

The string value used for string parameters.

Value

The integer value used for integer parameters.

Value

The float value used for float parameters.

Value

The float2 value used for float2 parameters.

Value

The float3 value used for float3 parameters.

Value

The float4 value used for float4 parameters.

See also

Geometry nodes