Jump to content

Iterate on each group separately


WaldoB

Recommended Posts

With the delete/copy node combination, I want to loop over each group of the input separately and combine the results at the end.

This is the input node:

post-10192-0-91077200-1377688009_thumb.p

As you see, it has two primitive groups.

In the delete node where this node flows into, I'd like to delete all groups except for the "current one". Basically, I'm looking for the HScript string expression that returns a group name by index.

Something like this:

primgrouplist("../all_junctions")[0]

Off course this doesn't work, because that just returns the first letter of the string returned by primgrouplist. How do I return thenth group in primgrouplist?

Thanks,

Waldo

Link to comment
Share on other sites

Hi, you can use a copy node with primgrouplist("../all_junctions") as the number of copies. Turn on stamping and create a variable (I usually call it "copy") and give it the value of $CY. In the delete, or blast, node you can use group`stamp("../copy1","copy",0)` to get each different group. For a preview you can change the 0 (the index).

  • Like 1
Link to comment
Share on other sites

Thanks for your reply Robert. That is what I had initially tried, but the problem with that is I have to assume what the incoming group names are. I need it to work with arbitrary group names.

ChristianW: possibly, can you show me how?

Link to comment
Share on other sites

So you're going to have groups coming in like "fizz01, twozz15, wipple236"?

Not "fizz01, 02, 03, 04" etc...

What exactly are you trying to do? Because forgetting what you called them in groups previously, you could do a connectivity and partition for the forEach to iterate over every object and do something on each object inside of the forEach.

Link to comment
Share on other sites

Yes, I cannot assume any incoming group name.

The connectivity/partition method works too, but that changes the group names. I need to preserve group names.

Yongbin's suggestion solves my problem, because I can get the groupname by index or in your case the FORIDXVALUE.

Thanks both of you for the suggestions!

Link to comment
Share on other sites

I made a mistake in my first post. For the delete copy method you need to also use the argc() expression so it becomes argc(primgrouplist("../all_junctions")) instead of just primgrouplist("../all_junctions"). Still doesn't give you the ability to use random group names though :(

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.

Guest
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...