sadhu Posted August 15, 2012 Share Posted August 15, 2012 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 Quote Link to comment Share on other sites More sharing options...
kgoossens Posted August 15, 2012 Share Posted August 15, 2012 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. Quote Link to comment Share on other sites More sharing options...
skogen Posted August 15, 2012 Share Posted August 15, 2012 hy! is this what you wanted to do with foreach? foreach_fix1.hipnc Quote Link to comment Share on other sites More sharing options...
sadhu Posted August 15, 2012 Author Share Posted August 15, 2012 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. Quote Link to comment Share on other sites More sharing options...
kgoossens Posted August 15, 2012 Share Posted August 15, 2012 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. Quote Link to comment Share on other sites More sharing options...
sadhu Posted August 15, 2012 Author Share Posted August 15, 2012 Thanks kgoossens. I will send this file to support to check. Quote Link to comment Share on other sites More sharing options...
old school Posted August 15, 2012 Share Posted August 15, 2012 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. Quote Link to comment Share on other sites More sharing options...
kgoossens Posted August 15, 2012 Share Posted August 15, 2012 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. Quote Link to comment Share on other sites More sharing options...
sadhu Posted August 15, 2012 Author Share Posted August 15, 2012 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? Quote Link to comment Share on other sites More sharing options...
sadhu Posted August 15, 2012 Author Share Posted August 15, 2012 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. Quote Link to comment Share on other sites More sharing options...
sadhu Posted August 15, 2012 Author Share Posted August 15, 2012 (edited) 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 Edited August 15, 2012 by sadhu Quote Link to comment Share on other sites More sharing options...
sadhu Posted August 15, 2012 Author Share Posted August 15, 2012 Sorry forgot to attach the file. foreach_test.hipnc Quote Link to comment Share on other sites More sharing options...
zarti Posted August 15, 2012 Share Posted August 15, 2012 this issue reminds of something similar weeks ago in a thread posted on official forum . and was not considered a bug from support , iirc . .cheers Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted August 15, 2012 Share Posted August 15, 2012 (edited) 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 August 15, 2012 by mantragora Quote Link to comment Share on other sites More sharing options...
kgoossens Posted August 24, 2012 Share Posted August 24, 2012 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. Quote Link to comment Share on other sites More sharing options...
old school Posted August 28, 2012 Share Posted August 28, 2012 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). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.