iterating over primitives in a group

   5914   4   0
User Avatar
Member
1 posts
Joined: June 2015
Offline
hello, i am quite new to houdini and i recently encountered a problem: i have a polygon which i divided by bricking. then i found all primitives that are too small and made a new group with them. next i made a foreach node, and wanted to iterate only by primitives in this group (to merge each one to its nearest neighbour). but foreach can only iterate over all primitives, i cant select specific group. how can it be done? also another question, inside foreach loop, if im iterating over primitives, how can i access its info (position, rotation, etc) to write in parameters?
User Avatar
Member
2536 posts
Joined: June 2008
Offline
You can always split your network into two paths. One path will delete the group and the other will delete all but the group. You operate upon each path independently then “Merge” them back to gather for the final result.

Inside the FOREACH you can lay down a Transform node and use the global variables $CEX,$CEY,$CEZ to gain access to the centroid (pivot center) of the primitive you are processing. This is how I scaled down each primitive in the group from it's own center. You can rotate and translate as well.

Attachments:
Screen Shot 2015-07-05 at 10.41.36 AM.png (46.2 KB)
Screen Shot 2015-07-05 at 10.41.15 AM.png (374.3 KB)
ap_foreach_primitive_group.hipnc (61.7 KB)

Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
8549 posts
Joined: July 2007
Online
For convenience you can as well use Split SOP instead of 2 delete nodes
Also it's always worth to evaluate if you really need to use foreach sop or mot as it's costly and many times can be avoided
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
2536 posts
Joined: June 2008
Offline
The FOREACH is convenient but I was not sure how to accomplish this without it. Do you have suggestions? I have started to see some examples where users are looping through data inside a Wrangle node.
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
8549 posts
Joined: July 2007
Online
Enivob
The FOREACH is convenient but I was not sure how to accomplish this without it. Do you have suggestions? I have started to see some examples where users are looping through data inside a Wrangle node.
it of course always depends on what you need to accomplish

so in some cases VEX is perfectly capable of replacing foreach - much faster
in others, like the one on your example can be easily done using Primitive SOP as attached - still much faster than foreach
while there are as well ones where you can't avoid Foreach SOP (unless you use similar technique like Copy SOP , Solver SOP, Gas Repeat etc. which would be similarly slow)

Attachments:
ap_foreach_primitive_group_alternative.hipnc (68.2 KB)

Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links