Houdini Resources

Updated on June 26  2024


For-Each Loops

Deborah R. Fowler



Houdini Looping - For Each including Variation

Posted Aug 11  2019
Updated Aug 2  2024 (All examples on this page tested in 20.5.278)

Houdini is multilingual. In particular, you can communicate with hscript, vex, vops (pictoral vex), python and less commonly C++ (HDK). If you are not familiar with the concept of looping, please see my introduction to programming.

There are many ways to create loops in Houdini including the for-each loop. This is a very powerful node, however it is also useful to understand the copy nodes beforehand. Wrangle nodes require some coding knowledge.
Instancing will be discussed separately.

This page is intended to go over the for-each node, however it is useful to understand the copy nodes beforehand.

 
The for-each construct is used here to make a circle of spheres, phyllotactic pattern, and a snowman.

Example file is circleOfSpheresAsForEach.hipnc

In a for-each node the "meta" data is used to grab the "iterator" or copy number.
In the tab menu there appear For-Each Number, Connected Piece, Named Primitive, Point and Primitive. These are simply presets and you can select the options from the parameters in the for-each nodes. Here we are using the for-each Number.





Other uses of for-each are when you are using "parts" of the specific geometry.
 
Note that the Houdini documentation has some excellent examples as well. There is an example of a copy star copied onto a sphere in the SideFX documentation.
Also, a soccer ball example from SideFX video and start file.

Copy stamping (discussed in copy options) is no longer recommended for variation. Variation can be achieved more efficiently with for-each or vex/create attribute/instancing nodes.
Examples:

Remember to use packed geometry.