Jump to content

How to access the iterating group inside Foreach SOP?

Recommended Posts

I have Font SOPs copied via the Copy SOP. I know I can do this with stamping but after the Copy SOP, I want to use a Foreach SOP to iterate over each group created by the Copy SOP. Inside the foreach, how can I copy each group with a different color?

Using the Color SOP with primitives, detail, points doesn't work. Is there a way to stamp the group name being iterated?

Link to comment
Share on other sites

Thanks Hopbin, I see what you mean. I tried copy*, it still worked though in H11. The problem is trying to generate different colors for the whole group but I think it requires storing the copy index too so you can randomize based on this. Color SOP still uses each primitive when you specify a group.

Link to comment
Share on other sites

Yeah this works with stamping. I just want to try this because I am wondering if I could access the whole group inside Foreach. Also would be useful if the geometry wasn't created with a Copy SOP, but had groups per object in the geometry.

Link to comment
Share on other sites

Ok well if you hadn't created the geo through a copy node (I have in the attached example, but ignore that fact), you can use a connectivitySOP to create an attribute per object, in this case "class" and then a partition sop to split the geo up into groups based on that attribute, in this case "box_*".

From there you can either use the $CLASS variable to colour each node differently, or use the groups in a for each...

Explanation of For Loop Expression:

rand(opdigits(stamps("..", "FORVALUE","")) * 523)

opdigits gets the number on the end of the string, so box_22 will return 22.

stamps(...FORVALUE...) will get you the current stamp name.

Hope this helps



  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...