For each loops in Houdini
For each loops
blendshape with FOR EACH LOOP example
(this creates transitions of 2 curves) add circle node primitive type: polygon divisions: 360 add for each number nodes (feed circle in foreach_begin) add null node (feed the foreach_begin node) add topobuild node (feed the foreach_begin node) press ENTER in viewport and start deforming points with brush add resample node (feed topobuild node) uncheck segment length segments: 360 treat polygon as: subdivision curves add fuse node add blend shapes node feed null into first input of blendshapes node feed fuse into second input of blendshapes node blend1: detail("../foreach_count1/","iteration",0) / 10 (for 10 iterations) then set output flag on foreach_end node and adjust the iterations
to separate the pieces
add attribute wrangle node (after blendshape node) (feed blendshape into 1st and foreach_count into 2nd input) VEXpression: @i = detail(1,'iteration'); then add a group node (after the foreach_end node) group type: points basegroup: @i=0 (no spaces!!) @i>0
nodegraph
┌─────────────┐ │ circle │ └──────┬──────┘ ┌──────────────────┐ │ │ foreach_count │ │ └──────────────────┘ │ ┌──────────┴─────────────┐ │ foreach_begin │ └──────────┬─────────────┘ ┌────────────┴─────────┐ │ │ ┌─────┴──────┐ ┌────────┴────────┐ │ NULL │ │ topobuild │ └─────┬──────┘ └────────┬────────┘ │ ┌───────┴────────┐ │ │ resample │ │ └───────┬────────┘ │ ┌───────┴──────┐ │ │ fuse │ │ └───────┬──────┘ └──────────┐ ┌───┘ │ │ ┌─────┴───────┴───────┐ │ blendshapes │ └──────────┬──────────┘ │ ┌────────────┴───────────┐ │ foreach_end │ └────────────────────────┘
cloner example
add box add for each network feed box into foreach begin node foreach begin node method: fetch feedback foreach end node iteration method: by count gather method: merge each iteration add transform node in between
scaling multiple objects individually
(for many single/packed objects) add for each connected piece node connectivity node -> connectivity type: primitive in for each loop add a transform node pivot translate: $CEX $CEY $CEZ
snow generator
(puts some snow on top of objects) add some test geo add attribute delete node remove uvs, mat add group node group name: topparts check keep by normal direction: 0 1 0 spread angle: 33 add connectivity node connectivity type: primitive attribute: name attribute type: string prefix: piece add for each named primitive node go inside and: add polyextrude node distance: 0 check transform extruded front transform space: global translate: 0 0.1 0 check output back add vdb from polygons node voxel size: 0.005 add vdb smooth sdf node filter voxel radius: 3 iterations: 4 add convert vdb node convert to: polygons add merge node and merge with test geo (or use labs snow buildup)
multithreaded for each loops
add compile block nodes move the for each loop nodes inside foreach_end node -> check multithread when compiled
to find out which nodes won't work in the foreach loops
in network view press D context specific badges tab -> non-compilable SOP badge change it to normal (now there will be an icon displayed next to the node if it won't work within the foreach loop)
object merge for each loop
https://www.youtube.com/watch?v=whg0Iy7qv8A
src
https://www.youtube.com/watch?v=AuLhysa9G-8 https://www.youtube.com/watch?v=FDXuZLn67so