Jump to content

foreach sop problem


sadhu

Recommended Posts

Hello.

* I am using a foreach sop to work on every polygon of thr grid.

* In foreach, I have one more foreach sop to process the incoming polygon 4 times.

* This setup is doing what I want to do but when I come out of the first foreach sop to see the output, I get all the polygons gathered at one place rather than maintaining their original position.

Please see the attached file.

Can someone please point out where am I going wrong.

Thanks

:)

foreach.hipnc

Link to comment
Share on other sites

Hello.

* I am using a foreach sop to work on every polygon of thr grid.

* In foreach, I have one more foreach sop to process the incoming polygon 4 times.

* This setup is doing what I want to do but when I come out of the first foreach sop to see the output, I get all the polygons gathered at one place rather than maintaining their original position.

Please see the attached file.

Can someone please point out where am I going wrong.

Thanks

:)

You have to give the second stamp name a different name. It seems like a bug but this way you can get around this.

Link to comment
Share on other sites

Thanks a lot for the reply guyes.

Hi kgoossens. Yes it is working by changing the name of forvalue. May I ask what made you think of changing it? Earlier this used to work without changing the name. It should work without doing this as we are specifing the address of forvalue.

Hi skogen. I could not open your file with H12.1.33, Houdini is crashing.

Thanks again.

:)

Link to comment
Share on other sites

Thanks a lot for the reply guyes.

Hi kgoossens. Yes it is working by changing the name of forvalue. May I ask what made you think of changing it? Earlier this used to work without changing the name. It should work without doing this as we are specifing the address of forvalue.

Hi skogen. I could not open your file with H12.1.33, Houdini is crashing.

Thanks again.

:)

Just experienced that problem in the past. I have several nodes using nested forloops. This is actually a good simple example to sent in as a bug report. Because it is an annoying bug.

Link to comment
Share on other sites

I don't know if you can call this a bug but submit it anyway.

The ForEach SOP utilizes stamping which means those variables are global to the entire scene and not local to that sub-folder. This means that for each ForEach iteration, you could use the stamp() or stamps() function above the ForEach SOP to change some values, same as the Copy SOP. I haven't tried a stamp() or stamps() function after the ForEach as it would only capture the last event unless you wrapped it around writing geometry to disk.

Link to comment
Share on other sites

I don't know if you can call this a bug but submit it anyway.

The ForEach SOP utilizes stamping which means those variables are global to the entire scene and not local to that sub-folder. This means that for each ForEach iteration, you could use the stamp() or stamps() function above the ForEach SOP to change some values, same as the Copy SOP. I haven't tried a stamp() or stamps() function after the ForEach as it would only capture the last event unless you wrapped it around writing geometry to disk.

Ah I didn't know it worked that way. Perhaps this should be addressed in the help file on the stamp name. Right now it mentions "You can use the stamp() expression to get at the value inside the ForEach sop". Which is confusing if it is not the case.

Link to comment
Share on other sites

Hi Jeff. I dont think I understood this. Please correct me if I am wrong.

There is foreach inside foreach.

So if I am inside the inner foreach & using stamp/s("..","FORVALUE",0) it will give me forvalue of the outermost for sop?

Link to comment
Share on other sites

Here is the responce I got from support.

As suggested in the forums, the solution is to rename the FORVALUE variable (MYVALUE, or something similar) and use that variable inside the sop.

This is not a bug.

The reason this is failing is that the same stamp value, FORVALUE, is being reused in each level. One gets away with this when you have a chain of foreach because the stamp expression specifying the ../ for the variable scope uniques the for loop. In a nested case this uniquing cannot occur as, for simplicity, all nested ops are considered to be in the same scope.

Link to comment
Share on other sites

I still didnt understand this. Does this mean topmost forvalue overwrites the inner forvalue (if both the values are same - FORVALUE)

I did a simple test.

I am processing each piece of a fractured geo using for sop by group (groupname piece). (FORVALUE - piece*)

Inside this foreach I am again fracturing this piece by scattering 3 points.

and processing these pieces using foreach by group (groupname - test). (FORVALUE - test*)

If I use font sop to find the forvalue in each for sop using same expression - stamps("..","FORVALUE","")I get the following output ( please refer attached image)

I should only see the forvalue of the outermost for sop printed?

Please help me understand this.

Thanks

post-4903-13450459907_thumb.jpg

Edited by sadhu
Link to comment
Share on other sites

Guest mantragora

I haven't looked at the file but from sound of what you are talking about it doesn't look like bug to me. In programming, if you got nested loops, you also have to use different variable name for each loop to get correct output.

Edited by mantragora
Link to comment
Share on other sites

  • 2 weeks later...

I haven't looked at the file but from sound of what you are talking about it doesn't look like bug to me. In programming, if you got nested loops, you also have to use different variable name for each loop to get correct output.

True, but in the node structure it feels weird because you reference not by name only. But also and to my intuition most importantly the node location.

Link to comment
Share on other sites

One way to think of the stamp variable is that it is global to the entire Houdini session. When the first ForEach SOP sets the stamp value to the variable name, it is global to everything in Houdini for this cook. When the second nested ForEach SOP evaluates within the same cook, it then tries to set it's stamp value to the same variable name and all manner of chaos ensues.

This is why the answer is to change the name of one of the stamp variables on one of the ForEach SOPs to avoid writing to the same global variable name across the cook.

And this also means you can use this stamp variable via the stamp() or stamps() function anywhere in the Houdini session. You could for example fetch a different image from the COP network. You could change the state of an object elsewhere in the scene. Heaven forbid change the stamp state of an external Copy SOP itself doing stamping (with a different stamp variable name please).

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