For each Group: What am I doing wrong?
19826 17 4- Soothsayer
- Member
- 862 posts
- Joined: 10月 2008
- Offline
I want to assign a random attribute value to each group, say a color value.
So, I break geometry and get many piece groups.
In ForEach SOP I set Group Mask to piece*
Inside the Foreach SOP I append a color node to the each1 node. In that color node I type: rand(stamp(“../”,“FORVALUE”,0))
but all my pieces have the same color. Where am I going wrong?
So, I break geometry and get many piece groups.
In ForEach SOP I set Group Mask to piece*
Inside the Foreach SOP I append a color node to the each1 node. In that color node I type: rand(stamp(“../”,“FORVALUE”,0))
but all my pieces have the same color. Where am I going wrong?
--
Jobless
Jobless
- Allegro
- Member
- 696 posts
- Joined: 3月 2006
- Offline
- stevenong
- Member
- 1631 posts
- Joined: 7月 2005
- Offline
- Soothsayer
- Member
- 862 posts
- Joined: 10月 2008
- Offline
- old_school
- スタッフ
- 2540 posts
- Joined: 7月 2005
- Offline
You could add a detail attribute to the SOP Tree when you are using attribute or group options. No need to use it in the counter method.
Initialize say i ($I) to 0 then do an $I+1 in an Attribute Create SOP. Each iteration will increment your detail attribute.
fyi, detail attributes ride on top of the geometry and you can only have a single entry per attribute. They tend to be very light though.
Initialize say i ($I) to 0 then do an $I+1 in an Attribute Create SOP. Each iteration will increment your detail attribute.
fyi, detail attributes ride on top of the geometry and you can only have a single entry per attribute. They tend to be very light though.
There's at least one school like the old school!
- Soothsayer
- Member
- 862 posts
- Joined: 10月 2008
- Offline
- old_school
- スタッフ
- 2540 posts
- Joined: 7月 2005
- Offline
First off that first group “inside0” was messing things up a bit so best to use the Group Mask piece* to only process the pieces you want.
The i detail attribute incrementor technique works when you toggle off merge results which makes sense. By not merging the results, you are passing the resulting geometry back through the SOP network and then the $I is incremented and kept. If merge results is off, then the input geometry is sampled fresh for each iteration.
So…
You can use the opdigits() expression on the group parameter reference in to the Each SOP. That will extract the trailing digit which should do what you want while keeping the merge results toggle on.
See the example file for both techniques where I used message (yes it gets annoying real fast) to visualize how the various techniques increment.
Surprising to see that the groups are not processed in order…
The i detail attribute incrementor technique works when you toggle off merge results which makes sense. By not merging the results, you are passing the resulting geometry back through the SOP network and then the $I is incremented and kept. If merge results is off, then the input geometry is sampled fresh for each iteration.
So…
You can use the opdigits() expression on the group parameter reference in to the Each SOP. That will extract the trailing digit which should do what you want while keeping the merge results toggle on.
See the example file for both techniques where I used message (yes it gets annoying real fast) to visualize how the various techniques increment.
Surprising to see that the groups are not processed in order…
There's at least one school like the old school!
- jacob clark
- Member
- 665 posts
- Joined: 7月 2005
- Offline
Hi Sooth,
In regards to the first question. Have a look here.
http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=16047&highlight= [sidefx.com]
cheers,
-j
In regards to the first question. Have a look here.
http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=16047&highlight= [sidefx.com]
cheers,
-j
- old_school
- スタッフ
- 2540 posts
- Joined: 7月 2005
- Offline
Nice custom hscript expression Jacob. Yeah use Jacob's method if your groups are not numbered sequentially.
As far as groups being processed randomly anyway, it really doesn't matter in many cases as long as you have a random number generated. Statistically speaking rand() should give you a 50% probability of being above 0.5 and below 0.5.
Ultimately it still would be nice to have your groups sequentially numbered. Bad Maya modelers, bad. lol
As far as groups being processed randomly anyway, it really doesn't matter in many cases as long as you have a random number generated. Statistically speaking rand() should give you a 50% probability of being above 0.5 and below 0.5.
Ultimately it still would be nice to have your groups sequentially numbered. Bad Maya modelers, bad. lol
There's at least one school like the old school!
- Soothsayer
- Member
- 862 posts
- Joined: 10月 2008
- Offline
- old_school
- スタッフ
- 2540 posts
- Joined: 7月 2005
- Offline
That expression is added to the Each SOP by default when you first place the Foreach SOP.
This expression simply returns the current group being processed as a string.
The first strcmp is used to see if you are using the group option, the second part returns the group name for you.
fortype and forstamp are actually the parameter names on the top ForEach SOP. ../ means go up one directory (which is the ForEach SOP) then fetch the parameter values from fortype and forstamp.
If I want to use the group name specifically, I just RMB on this parm and copy the parm then past relative reference and voila, you get the current group name being processed. I see many users copying the literal expression. No need to that. Just a chs() channel reference to this parm gets you the group name.
This expression simply returns the current group being processed as a string.
The first strcmp is used to see if you are using the group option, the second part returns the group name for you.
fortype and forstamp are actually the parameter names on the top ForEach SOP. ../ means go up one directory (which is the ForEach SOP) then fetch the parameter values from fortype and forstamp.
If I want to use the group name specifically, I just RMB on this parm and copy the parm then past relative reference and voila, you get the current group name being processed. I see many users copying the literal expression. No need to that. Just a chs() channel reference to this parm gets you the group name.
There's at least one school like the old school!
- Tom Freitag
- Member
- 84 posts
- Joined: 7月 2013
- Offline
hey,
some years later. Helpful thread. But I have propblem accessing details attribute from last iteration..to sum up my detail attrib at end.
the foreach is driven by attribute value.
for each example(last row is what i want):
iteration detailattrib result (sum every iteration)
1 ————> 5 ———> 5
2. ———–> 3 ———> 8
3. ———–> 2 ———–> 10
4. ———–> 4 ———–>14
..
My idea: sum=sum(current iteration)+sum(last iteration)
BUT I can't using “MERGE RESULTS” !!
any advice would be great!.
thanks, tom.
some years later. Helpful thread. But I have propblem accessing details attribute from last iteration..to sum up my detail attrib at end.
the foreach is driven by attribute value.
for each example(last row is what i want):
iteration detailattrib result (sum every iteration)
1 ————> 5 ———> 5
2. ———–> 3 ———> 8
3. ———–> 2 ———–> 10
4. ———–> 4 ———–>14
..
My idea: sum=sum(current iteration)+sum(last iteration)
BUT I can't using “MERGE RESULTS” !!
any advice would be great!.
thanks, tom.
- tamte
- Member
- 8621 posts
- Joined: 7月 2007
- Offline
- Tom Freitag
- Member
- 84 posts
- Joined: 7月 2013
- Offline
hey tamte,
big thanks for trying to help
First my fail: I need to CHECK “merge results”, of course.
Since I am working on a tree generator, the most stuff is happening inside the foreach stuff. If I useing feedback-loop, everything is exploding ;(
So I don't have something like a feedback, its only merge every iteration at the end of sops level (like jeff explained above).
I can't look back to my last iteration like stamp(“..”,“FORVALUE”,0) - 1
So I have rebuild my problem i a reayl simple scene, which I have attached.
I tried a lot the last 2 day…but now my brain is bending
thx. tom
big thanks for trying to help
First my fail: I need to CHECK “merge results”, of course.
Since I am working on a tree generator, the most stuff is happening inside the foreach stuff. If I useing feedback-loop, everything is exploding ;(
So I don't have something like a feedback, its only merge every iteration at the end of sops level (like jeff explained above).
I can't look back to my last iteration like stamp(“..”,“FORVALUE”,0) - 1
So I have rebuild my problem i a reayl simple scene, which I have attached.
I tried a lot the last 2 day…but now my brain is bending
thx. tom
- tamte
- Member
- 8621 posts
- Joined: 7月 2007
- Offline
- Tom Freitag
- Member
- 84 posts
- Joined: 7月 2013
- Offline
tamte, thanks for taking time and replying so fast. Especially from you
i could feel what you mean…to recreate the “merge results” inside a feedback loop. But it seems to be a big change for tiny little problem.
Like I mentioned before its for a treegenerator. Every branch generation I want to happen in a linear fashion, not inside a feedback loop. So one node for every generation to get the unique controll(distribution, shaping) for every iteration/generation.
i could feel what you mean…to recreate the “merge results” inside a feedback loop. But it seems to be a big change for tiny little problem.
Like I mentioned before its for a treegenerator. Every branch generation I want to happen in a linear fashion, not inside a feedback loop. So one node for every generation to get the unique controll(distribution, shaping) for every iteration/generation.
- tamte
- Member
- 8621 posts
- Joined: 7月 2007
- Offline
don't worry, it's simple enough
here are 2 methods
1. foreach in feedback mode, processing each iteration the same way as if merge results was on (just geo of the same attrib value), then adding it to accumulated geo from previous iterations and summing the attrib or whatever
2. foreach in merge results mode, but creating additional point per iteration holding your desired data
after foreach splitting the geo and data points, accumulating value of data points as geo detail attrib
here are 2 methods
1. foreach in feedback mode, processing each iteration the same way as if merge results was on (just geo of the same attrib value), then adding it to accumulated geo from previous iterations and summing the attrib or whatever
2. foreach in merge results mode, but creating additional point per iteration holding your desired data
after foreach splitting the geo and data points, accumulating value of data points as geo detail attrib
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- Tom Freitag
- Member
- 84 posts
- Joined: 7月 2013
- Offline
-
- Quick Links