Houdini 20.0 Nodes LOP nodes

For Each

The end node of a For-Each loop block.

On this page
Since 17.0


The For Each LOP repeats a set of operations multiple times, offering options to alter parameters during each iteration. This node forms a block with a Begin Context Options Block node connected through its third input, and the nodes in between the start node and this node’s third input are the operations that will be repeated. Setting the Iteration method determines whether this node re-cooks the loop over a range of numbers or a list of primitive paths.

The start node is a context options node because the for-each block uses context option variables to hold the iteration counters. Unlike the For Each SOP nodes, this node does not intrinsically isolate the affected prims within the loop. It just the context option values, with the number or primitive path for each loop, and cooks the nodes.

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.


The context option generated by a for-each block leaks through to the target of a Fetch LOP. Even though the hull does not encompass the fetched nodes, they should be considered within the block and are able to use the context options accordingly. This may or may not be expected behavior.

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.

loopnum = hou.contextOption("ITERATION")

You may find it useful to use Python’s extensive library of string and path manipulation functions to pull information out of the ITERATIONVALUE.

Do not use hou.setContextOption() in a loop. Context options propagate up the network chain, not down. If you want to define variables for use in expressions within the loop, use an Edit Context Options LOP at the end of looping part of the network (usually connected directly to the third input of the For Each LOP).


  • 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.

Combine Iterations

Separate Layers

Each iteration from the third input is added into a new sublayer stack in the output, sorted by strongest to weakest from the strongest (last) iteration, then strongest to weakest from the next strongest (second-to-last) iteration, and so on.

This includes layers from above a Layer Break node, which allows such layers to continue to provide context for all subsequent layers.

Separate Layers, File Layers Weakest

Like “Separate Layers” (above), except that any sublayers that refer to existing layer files on disk are ordered to be weaker than any layers authored purely in the LOP network.

This is useful when combining several LOP node streams where each stream begins with one of more file layers, then applies modifications to a new layer on top of that layer. After merging these streams, all the LOP-authored modification layers will be adjacent to each other in the sublayer list for the stage. This allows all these new layers to be flattened into a single layer by the USD ROP without also flattening the layers from disk. (In the regular Separate Layers mode, layers from disk would alternate with layers authored in LOPs, and each LOP layer would have to be saved to a separate new layer on disk.)


This option can change the result of composing the stage if the opinions from layers on disk were intended to be stronger than opinions authored in the LOP network.

Separate Layers, File and SOP Layers Weakest

Like “Separate Layers, File Layers Weakest” (above), except that sublayers imported from SOP nodes are also sorted with files loaded from disk, appearing before any layers authored purely in the LOP network.

This is useful when you want the layers authored from SOPs to be saved to separate layers rather than flattened together with the layers authored in the LOP Network.

Flatten Layers

All layers from all iterations are flattened together into a single output layer.

Layers from above Layer Break nodes are removed prior to flattening and so do not contribute to the output.

Flatten Into First Input Layer

The layers from all the iterations are flattened into the active layer of the first input.

Layers from above Layer Break nodes other than on the first input are removed prior to flattening and so do not contribute to the output.

Flatten Each Input

For each iteration its layers are flattened, and then the flattened iterations are added to a new sublayer stack in the output.

Layers from above Layer Break nodes are removed prior to flattening and so do not contribute to the output.

Strip Layers Above Layer Breaks

Enable this option to remove all layers created above Layer Break nodes on every input to this node. This is the default option since usually a layer break operation is used to separate data generated by the For Each iterations from data authored prior to the For Each Begin node, and thus prevent duplicate copies of the data outside the loop from being added to the stage. However in some cases, such as when different iterations follow different cook paths, it may be useful to preserve the layers from above layer breaks. As noted in the Combine iterations description, some values of that parameter may cause layers from above layer breaks to be stripped in spite of this option being turned off.

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.

  • Asset Reference

    Reference, Transform, and select variants of a USD Asset.

  • 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.

  • Assign Prototypes

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

  • 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.

  • Background Plate

    Sets up hold-out or matte objects that leave holes in the scene through which the background is visible. These prims still take shadows and contribute to reflections as if they were the background.

  • 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 collections using primitive patterns.

  • Component Geometry

    Geometry container or import source, in a network created by the Component Builder tool.

  • Component Geometry Variants

    Sets up geometry variants, in a network created by the Component Builder tool.

  • Component Material

    Assigns materials to geometry in a network created by the Component Builder tool.

  • Component Output

    Assembles the final Component prim, in a network created by the Component Builder tool.

  • 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.

  • Coordinate System

    Define named coordinate systems used in shaders.

  • Copy Property

    Copy properties from one primitive to another, or renames properties on a primitive.

  • 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 Material Properties

    Lets you build a spare parameter interface that reflects material or shader input attributes to directly edit their values.

  • Edit Properties

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

  • Edit Properties From Node

    Lets you refer to the parameter on another node to directly edit attribute and relationship values.

  • Edit Prototypes

    Modify the prototypes of native or point instances in-place, without disturbing the instancing setup.

  • 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.

  • File Cache

    Caches (writes out once and then reads from) USD layers (possibly animated) to disk.

  • Follow Path Constraint

    Constrains a prim to follow a path curve.

  • For Each

    The end node of a For-Each loop block.

  • Geometry Clip Sequence

  • 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.

  • Houdini Feather Procedural

    Generates feathers for rendering.

  • Houdini Preview Procedurals

    Invokes Houdini Procedurals while working interactively.

  • Houdini Procedural: Hair

    Houdini Hair Procedural for Solaris.

  • Houdini Procedural: Ocean

    Houdini Ocean Procedural for Solaris.

  • 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.

  • Instancer

    Create multiple render products sharing common settings.

  • Isolate Scene

    Work in masked areas of the stage.

  • Karma

    Renders the USD scene using Houdini’s Karma renderer.

  • Karma Cryptomatte

    Setup Cryptomatte AOVs for Karma.

  • Karma Fog Box

    Creates a constant volume within a box.

  • Karma Physical Sky

    Creates a Karma Sky Dome and Sun Light rig.

  • Karma Render Properties

    Configure Render Properties for Karma.

  • Karma Sky Dome Light

    Creates or edits a Karma Sky Dome Light.

  • Karma Standard Render Vars

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

  • LPE Tag

    Manage Lights' LPE Tags.

  • Labs Karma AOVs for RenderMan Denoiser

    Generates AOVs for the Pixar RerderMan denoiser.

  • Labs RizomUV Optimize

  • Labs RizomUV Rectangularize

  • Labs RizomUV Unwrap

  • 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.

  • Layout

    Provides tools for populating a scene with instanced USD assets. You can place individual components, paint/scatter components in different ways using customizable brushes, and edit existing instances.

  • Light

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

  • Light Filter Library

    Authors USD light filter primitives from VOP nodes.

  • 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.

  • Match Size

    Resizes and recenters the input geometry to match a reference bounding box.

  • 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.

  • Merge Point Instancers

    Merges point instancers into a single consolidated point instancer.

  • Mesh

    Creates or edits a mesh shape primitive.

  • Modify Paths

    Modify asset path attribute values.

  • Modify Point Instances

    Modifies point transforms and property values for individual point instances.

  • Motion Blur

    Adds time samples to allow motion blur when rendering.

  • 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 for a fracturing simulation in USD, also useful as a canned effect.

  • Reference

    References the contents of a external USD files and/or layers created by other LOP nodes into a branch of the existing scene graph tree. Can also remove or replace 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).

  • Resample Transforms

    Generates interpolated transform time samples from existing time samples on USD prims.

  • Restructure Scene Graph

    This node has various operations for editing prim paths, variant sets, and composition arcs.

  • Retime Instances

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

  • SOP Character Import

    Imports a character or animation from a SOP network into the USD scene graph.

  • 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 Crowd Import

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

  • 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 Doctor

    Validates primitives on a USD stage.

  • 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 Point Instancers

    Splits a point instancer into two or more instances, which divide up the original instances.

  • Split Primitive

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

  • Split Scene

    This node splits a scene graph into two disjoint sets of primitives.

  • 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

  • Unassign Material

    Unbinds a material from one or more USD primitives.

  • 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.