How to iterate over groups in H16.5?

   14687   4   0
User Avatar
Member
6 posts
Joined: Jan. 2016
Offline
Hello dear Community,

in earlier versions I could iterate over groups with the old for-each networks. How would I do that in the current version? I grouped Prims in several groups and now I want to perform a set of actions on each group. I don't see any option for that in the new nodes. Can someone help me out here?

Best regards,
Nicolas
User Avatar
Member
2534 posts
Joined: June 2008
Offline
There is a special syntax where you use the ‘group’ prefix to access groups inside of a wrangle. So it is easy to examine the contents of a group with an IF statement.

if (@group_grp_RED) {
    v@Cd = set (1,0,0);
}
if (@group_grp_GREEN) {
    v@Cd = set (0,1,0);
}
if (@group_grp_BLUE) {
    v@Cd = set (0,0,1);
}
So the actual group name is ‘grp_RED’ not ‘group_grp_RED’.

Attachments:
ap_color_by_group_in_loop.hiplc (76.0 KB)
Untitled-1.jpg (229.8 KB)

Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
Use a Name node to turn your groups into a ‘name’ attribute before piping into the new for each nodes:
Edited by bonsak - Dec. 5, 2017 09:06:27

Attachments:
foreach-over-groups.hip (75.7 KB)
houdinifx_2017-12-05_15-05-25.png (14.3 KB)

http://www.racecar.no [www.racecar.no]
User Avatar
Member
1 posts
Joined: April 2015
Offline
Yes, use name SOP is a better way.

But you can still use the old foreach subnet. It is hidden in the tab menu, but can be create by using python script

Let's say you already have geo1 in /obj, then:

hou.node('/obj/geo1').createNode('foreach')
  • Quick Links