Houdini 18.5 Nodes LOP nodes

For Each

The end node of a For-Each loop block.

On this page
Since 17.0


This node forms a block with a Begin Context Options Block node connected through its third input. This node loops over the nodes wired in between the start node and this node’s third input, cooking them multiple times based on the Iteration method.

(The start node is a context options node because the for-each block uses context option variables to hold the iteration counters).

This has several uses:

  • Generating a certain number of prims, attributes, edits, or whatever you need, automatically.

  • Applying a series of changes to a bunch of primitives.

  • Applying a series of changes to all variant sets on a bunch of primitives, or to all variants.

How to

  1. In the LOP network, press ⇥ Tab and choose For Each.

    This puts down a block starting with a Begin Context Options Block node and ending with this node.

  2. Wire the incoming node chain into the foreach_end node’s first input.

    If you are only adding to the stage (for example, creating new prims), you don’t need to wire anything into the foreach_begin. However, if you are modifying existing prims, you should also wire the incoming node chain into the foreach_begin node’s input, so it’s available in the loop.

  3. Select For Each node at the end of the block (foreach_end).

  4. In the node’s parameters, choose the Iteration method.

  5. In between the foreach_begin node and the foreach_end node’s third input, wire in the LOP nodes you want to loop over.

    The For Each node cooks the block zero or more times (according to the Iteration method). The results are flattened and added as a sublayer over the incoming stage from the first input.

Loop variables

On the nodes inside the block, you can access context options containing the current iteration number (ITERATION) and the total number of iterations (NUMITERATIONS).

Some iteration methods also set an ITERATIONVALUE variable. The contents of the variable depends on the iteration method. For example, when iterating over primitives, the ITERATIONVALUE contains the scene graph path of the current prim. See the help for the Iteration method parameter below.


You can rename the looping variables using parameters on the For Each node (see below). If you are nesting for-each loops, you should rename the variables so each loop level has different variable names, so you can tell them apart.

For example, if you had a "for each variant set" loop and inside that loop a "for each variant" loop, you might rename the outer variables to VARSET_ITERATION and NUM_VARSETS, and the inner variables to VARIANT_ITERATION and NUM_VARIANTS.

In expressions

To get the value of a context option in an expression inside the loop, use @name, for example:


or use the contextoption expression function:


For example, if you want to create 100 lights inside the /lights prim, named /lights/light_0 to /lights/light_99, you would put a Light node in the loop block and set its Primitive path to the following expression:


(Remember in string parameters, you must surround expression code with backticks.)

In Python

To get the value of a context option in Python inside the loop, use the hou.contextOption() function.

You may find it useful to use Python’s extensive library string- and path-manipulation function to pull information out of the ITERATIONVALUE. You can create new context options using hou.setContextOption().

For example, at the start of a "for each primitive" loop, you could insert a Python Script LOP that makes new context option variables containing the parent path and prim name, extracted from the full primitive path.

# Get the path of the current primitive from the context option
full_prim_path = hou.contextOption("ITERATIONVALUE")
# Find the index of the last slash in the path string
last_slash = full_prim_path.rfind("/")
# Make a new "PARENTPATH" context option containing everything up
# to the last slash
hou.setContextOption("PARENTPATH", full_prim_path[:last_slash])
# Make a "PRIMNAME" context option containing everything after the
# last slash
hou.setContextOption("PRIMNAME", full_prim_path[last_slash + 1:])

Then you could use @PARENTPATH and @PRIMNAME in expressions on the other nodes in the loop.


  • Leave the Perform layer break parameter on in the Begin Context Options Block node at the start of the loop block.

    Without this option enabled, any nodes above the Begin Context Options Block node would be included in each loop and uselessly combined with every other iteration (uselessly because the data will be the same on each cook).

  • Because this block uses context options to hold the iteration variables, it works quite differently from For-Each loops in other network types.

  • To edit every variant in a certain variant set on selected prims:

    • Make an outer "for each prim" loop over the prims. Set the Primitives parameter to select the prims you want to edit. Change the name of the ITERATIONVALUE variable in this loop to PRIMPATH.

    • Make an inner "for each variant" loop. Change the name of the ITERATIONVALUE variable in this loop to VARIANTNAME.

    • Now in the inner loop you can supply both the current primitive’s scene graph path as @PRIMPATH and the current variant’s name as @VARIANTNAME in nodes to edit the variant.


First input

Connect the incoming stage to this input. The node flattens the results of looping over the nodes connected to the third input, and then overlays it as a new layer on this stage in the output.

Second input

The Iteration method has options to loop over prims/variant sets/variants from this input instead of from the first input. This lets you drive the iteration using a separate stage other than the stage being modified.

The data in this input is never included in this node’s output. It may be used as to drive iteration, depending on the Iteration method setting.

Third input

This input is re-cooked for each iteration. The node flattens together the layers generated on each iteration, and composes the flattened result onto the stage from to the first input.


Iteration Method

How this node loops/what it loops over.

For Number of Iterations

Loops a set number of times. Note that you can drive the number of iterations dynamically with an expression in the Iterations parameter.

This method sets ITERATIONVALUE to the same value as ITERATION (the current loop count, starting from 0).

For Each Primitive in First Input

Loops over each primitive selected by the primitive pattern in Primitives (from the first input).

This method sets ITERATIONVALUE to the full path of the current prim.

This option is useful for performing edits on a set of primitives.

For Each Variant Set in First Input

Loops over each variant set on a certain prim (or prims). The primitive pattern in Primitives selects the prim(s) holding the variant sets (from the first input).

This method sets ITERATIONVALUE to the name of the current variant set.

You can use this add variants to or remove variants from variant sets. You could also nest another For-Each loop inside using "For each variant in first input" to loop over each variant in each variant set.

For Each Variant in First Input

Loops over each variant in a named variant set on a certain prim (or prims). The primitive pattern in Primitives selects the prim(s) holding the variant sets (from the first input).

This method sets ITERATIONVALUE to the name of the current variant.

This method does not change the variant selection.

For Each String in Parameter

Loops over each string provided in the Iterate Over Strings parameter. The number of iterations will be defined by the number of separate strings specified in the parameter.

This method sets ITERATIONVALUE to the current string from the parameter.

You can also choose to drive iteration using data from the second input instead of the first input. If for some reason the things you want to loop over are in another node chain, you can connect it to the second input and use these options. Note that data from the second input is never included in this node’s output. It is only used to drive the iterations, if you choose one of the "in second input" options.


When Iteration method is "For Number of Iterations", this is the number of loops. (You can use an expression in this parameter to drive the number of loops based on something else.)


When Iteration method is "For each primitive", "For each variant set", or "For each variant", the prims to look at. You can drag primitives from the scene graph tree pane into this textbox to add their paths, or click the select button beside the text box to select the primitives in the viewer. You can also use primitive patterns for advanced matching, including matching all prims in a collection (using /path/to/prim.collection:name).

Variant Set

When Iteration method is "For each variant", the name of the variant set to loop over.

Iterate Over Strings

When Iteration method is "For each string in parameter", the list of strings to loop over. Individual strings are separated by white space. Quotes can be used around a string to incorporate white space into that value.

Flatten Iterations Into First Input Layer

When this is off (the default), the edits created in the loop are added to the first input as a new sublayer. When this is on, the edited created in the loop are flattened onto the first input’s active layer (does not create a new layer).

Set Last Modified Primitives from Iteration input

Iteration Option Name

The name of the context option variable this node will create holding the current loop number (starting from 0). You can rename this for convenience or to make nested loops use unique names.

Iteration Count Option Name

The name of the context option variable this node will create holding the total number of loops. You can rename this for convenience or to make nested loops use unique names.

Value Option Name

The name of the context option variable this node will create holding Iteration method-specific information (the current iteration for "Number of iterations", the current prim path for "For each primitive", the variant set name for "For each variant set", or the variant name for "For each variant"). You can rename this for convenience or to make nested loops use unique names.

Iteration Range

This lets you optionally restrict the number of iterations the node would normally perform to start and end within a certain range. This can be useful for debugging, to observe the effect of just a "slice" of the overall result.

All Iterations

Run all available iterations (the default, normal operation).

Single Iteration

Only run one iteration, specified in the First iteration parameter. The loop numbers start at 0.

Range of Iterations

Only run a range of iterations, from the First iteration until the Last iteration (inclusive). For example, if you set Iteration method to "For number of iterations" and set the number to 5, you would get iterations 0, 1, 2, 3, and 4. If you then set Iteration range to "Range", First iteration to 1, and Last iteration to 3, you would only get iterations 1, 2, and 3.

First iteration

When Iteration range is "Single", only run this iteration number. When Iteration range is "Range", only run a subset of iterations starting at this number. The first iteration is numbered 0.

Last iteration

When Iteration range is "Range", only run a subset of iterations including but ending at this number. The first iteration is numbered 0.

LOP nodes

  • Add Variant

    Adds one or more variants to a variant set on a primitive. This node creates the primitive if it doesn’t exist.

  • Additional Render Vars

    Create multiple render vars.

  • Assign Material

    Assigns a material to one or more USD primitives. You can use also programmatically assign materials using VEX, programmatically override material settings for each assignment, and programmatically assign materials to geometry subsets.

  • Attribute VOP

    Create/edit USD attribute values using a VOP network.

  • Attribute Wrangle

    Create/edit USD primitive attributes using a VEX snippet.

  • Auto Select LOD

    Automatically selects a level-of-detail variant based on the primitive’s distance from the camera.

  • Bake Skinning

    "Bakes" animation driven by a UsdSkel into transforms and point positions.

  • Basis Curves

    Creates or edits a basis curves shape primitive.

  • Begin Context Options Block

    This node begins a block of LOP nodes, within which certain context options have certain values.

  • Blend

    Partially applies edits to a layer’s attributes based on a fractional weight.

  • Blend Constraint

    Blends transforms according to a list of weights specified as parameters.

  • Cache

    Caches the results of cooking the network at different times, increasing playback speed.

  • Camera

    Adds a USD camera to the scene.

  • Capsule

    Creates or edits a "capsule" (tube with hemispherical ends) shape primitive.

  • Collection

    Creates/edits a collection using selected prims.

  • Collection

    Creates/edits collections using primitive patterns.

  • Cone

    Creates or edits a cone shape primitive.

  • Configure Layer

    Edits metadata on a layer.

  • Configure Primitives

    Edits various metadata on one or more primitives.

  • Configure Properties

    Configures metadata on properties (relationships and attributes).

  • Configure Stage

    Configures metadata for how to load layers into the stage and asset resolution.

  • Create LOD

    Uses the PolyReduce SOP to automatically generate multiple levels of detail from a high-res model, and stores them as USD variants.

  • Cube

    Creates or edits a cube shape primitive.

  • Cylinder

    Creates or edits a cylinder shape primitive.

  • Distant Light

    Creates or edits a USD Distant Light, representing a far-off light source such as the sun. Adds some useful Karma-specific attributes.

  • Dome Light

    Creates or edits a USD Dome Light prim. A dome light emits light inward, simulating light coming from the sky/environment surrounding the scene.

  • Drop

    Runs a simulation to drop primitives under gravity.

  • Duplicate

    Creates copies of a prim (and its descendants).

  • Edit

    Interactively transforms prims in the viewer. Can use physics collisions to position props realistically.

  • Edit Context Options

  • Edit Material

    Allows you to edit an existing USD material by modifying parameters and shader connections. This can be useful if the existing material is on a non-editable layer.

  • Edit Properties

    Lets you build a spare parameter interface to directly edit attribute and relationship values.

  • Edit Prototype

    Switch point instances or USD instanceable prims to instance a different prototype.

  • Edit Target Layer

    Allows you to apply edits directly in a lower layer, instead of overriding prims and attributes in the active layer.

  • Error

    Generates a message, warning, or error, which can show up on a parent asset.

  • Explore Variants

    Visualize, set, or extract variants on primitives.

  • Extract Instances

    Converts ("heroes") an instance into a "real" editable prim.

  • Fetch

    Grabs the output of another LOP, potentially in another LOP network.

  • Follow Path Constraint

    Constrains a prim to follow a path curve.

  • For Each

    The end node of a For-Each loop block.

  • Geometry Sequence

    Imports a sequence of geometry files into LOPs as animated geometry.

  • Geometry Subset VOP

    Creates USD geometry subsets within geometry prims (similar to groups in SOPs) based on evaluating a VEXpression or VOP network.

  • Graft Branches

    Takes prims/branches from the second input and attaches them onto branches of the scene graph tree in the first input.

  • Graft Stages

    Takes scene graph trees from other inputs and attaches them onto branches of the scene graph tree in the first input.

  • HDA Dynamic Payload

    Cooks a OBJ or SOP asset on disk and imports the animated geometry output as a USD payload.

  • Hermite Curves

    Creates or edits a hermite curves shape primitive.

  • Inline USD

    Parses usda code representing a layer and adds it to the layer stack.

  • Insertion Point

    Represents a point in the node graph where nodes can be inserted.

  • Instancer

    Instances or copies primitives onto points.

  • Karma Procedural

    Sets up render-time instantiation for Karma.

  • Karma Render Properties

    Configure Render Properties for Karma (Beta).

  • Karma Standard Render Vars

    Create standard karma render vars (AOVs/Image Planes).

  • LOP nodes

    LOP nodes generate USD describing characters, props, lighting, and rendering.

  • Layer Break

    Starts a new active sublayer that subsequent nodes will edit, and indicates all previous layers will be discarded when saving to disk.

  • Layer Replace

    Replaces all uses of a certain layer with a substitute layer from its second input.

  • Light

    Creates or edits a USD Light prim. This node also adds some useful Karma-specific attributes.

  • Light Linker

    Creates USD light link properties based on rules.

  • Light Mixer

    Lets you interactively edit USD properties for multiple lights.

  • Load Layer for Editing

  • Loft Payload Info

    Adds basic information from inside a payload to the primitive that loads the payload.

  • Look At Constraint

    Constrains a prim to always point toward a target.

  • Mask from Bounds

    Sets a primvar based on whether/by how much selected prims are inside a bounding shape.

  • Material Library

    Authors USD material primitives from shader VOP nodes.

  • Material Linker

    Creates material assignments based on rules.

  • Material Variation

    Creates attributes/primvars to override material parameters per-prim/instance.

  • Merge LOP

    Merges the layers from incoming stages into a unified layer stack.

  • Mesh

    Creates or edits a mesh shape primitive.

  • Modify Point Instances

    Modifies point transforms and property values for individual point instances.

  • Null

    This node does nothing. It can be useful to insert a Null into a network as a "fixed point" in the network that you can refer to by name in expressions/scripts.

  • Output

    Represents the output of a subnetwork. Allows you to design a node asset with multiple outputs.

  • Parent Constraint

    Makes a primitive appear to inherit the transform hierarchy of another prim somewhere else in the tree.

  • Points

    Creates or edits a Points shape primitive.

  • Points Constraint

    Position and Orient primitives using point positions from a geometry.

  • Primitive

    Bulk-creates one or more attributes of a certain type.

  • Prune

    Hides or deactivates primitives and point instances.

  • Python Script

    Lets you write Python code in the node to use the USD API to directly manipulate the stage.

  • RBD Destruction

    An example of how to a fracturing simulation in USD, also useful as a canned effect.

  • Reference

    References the contents of an external USD file into a branch of the existing scene graph tree, or removes/replaces existing references.

  • Render Geometry Settings

    Applies renderer-specific geometry settings to geometry in the scene graph.

  • Render Product

    Creates or edits a UsdRenderProduct prim, which represents an output of a renderer (such as a rendered image file or other file-like artifact produced by a renderer), with attributes configuring how to generate the product.

  • Render Settings

    Creates or edits a UsdRenderSettings prim, which holds the general settings for rendering the scene.

  • Render Var

    Specifies a custom variable computed by the renderer and/or shaders, either a shader output or a light path expression (LPE).

  • Retime Instances

    Offsets and/or scales the timing of animation on selected instances.

  • SOP Create

    Lets you create geometry in a SOP subnetwork inside this node, so you can create geometry in-place in the LOP network instead of needing a separate SOP network.

  • SOP Import

    Imports geometry from a SOP network into the USD scene graph.

  • SOP Modify

    Converts USD geometry into SOP geometry, runs the SOP subnet inside this node on the geometry, and converts the changes back to USD overrides.

  • Scene Import

    Imports models, materials, and lights from the Object level into the LOP network.

  • Scope

    Creates a "scope" primitive. Scope is the simplest form of grouping, and does not have a transform. Scopes can be useful for organizing the scene tree.

  • Set Extents

    Sets the bounding box metadata of selected primitives.

  • Set Variant

    Selects (switches to) one of the variants stored in a variant set on a primitive.

  • Simulation Proxy

    Generates low-poly collison geometry suitable for physical simulation and creates a proxy relationship to the original model.

  • Sphere

    Creates or edits a sphere shape primitive.

  • Split Primitive

    Splits USD geometry prims into child primitives based on geometry subsets or primvar values.

  • Stage Manager

    Provides a convenient interface to reference in many files at once and place them in the scene graph tree.

  • Store Parameter Values

    Lets you store temporary (unsaved) data in the stage.

  • Sublayer

    Imports from USD files or other LOP node chains into as sublayers, or removes/replaces/reorders existing sublayers.

  • Subnet

    Encapsulates a LOP subnetwork, allowing you to organize and hide parts of the network.

  • Surface Constraint

    Constrain a prim to stick to a surface.

  • Switch

    Passes through one of several inputs, based on a parameter choice or expression.

  • TimeShift

    Outputs the stage as it is at a different point in the timeline.

  • Transform

    Edits the transforms of selected USD primitives.

  • Transform UV

    Moves, rotates, and scales texture coordinates on USD primitives.


  • USD Render ROP

  • Value Clip

  • Vary Material Assignment

    Assign different materials across a number of prims to create variation.

  • Volume

    References volume data on disk into a volume prim containing field prims.

  • Xform

    Creates or edits an Xform prim. Xform (and its sub-classes) represents a transform in the scene tree.