philpappas Posted March 22, 2019 Share Posted March 22, 2019 Hello, i trying to do something simple but i am knid of new to houdini so i dont know the tricks yet. i have a float number in a for loop that i want to divide by two every iteration. What is the appropriate expression for that? Quote Link to comment Share on other sites More sharing options...
woodenduck Posted March 22, 2019 Share Posted March 22, 2019 Hit the Create Meta Import Node on the Block Begin node and plug that in to the 2nd input of an Attribute Wrangle. Then loop over the geo inside the forloop according to the number of the iteration. for(int i = 0; i < detail(1, "iteration", 0)+1; i++) { f@myAtt /= 2; } Quote Link to comment Share on other sites More sharing options...
bonsak Posted March 22, 2019 Share Posted March 22, 2019 You could do it like this: f@number = 100; for(int i = 1 ; i < 10; i++){ f@number /= 2; printf('N divided by 2 is %g \n', @number); } -b Quote Link to comment Share on other sites More sharing options...
philpappas Posted March 22, 2019 Author Share Posted March 22, 2019 problem is when inside the for loop, btw i am using the nodes not vex, for some reason i cant access the detail attribute from outside the loop. i am using this expression inside a parameter field detail("../nodename/", attributename,0); Quote Link to comment Share on other sites More sharing options...
woodenduck Posted March 22, 2019 Share Posted March 22, 2019 Not sure I understand what you're trying to do. Can you post a hip file? Quote Link to comment Share on other sites More sharing options...
philpappas Posted March 22, 2019 Author Share Posted March 22, 2019 yes here, i've uploaded the part i am trying to fix i want to divide the base_val detail attribute every iteration test.hip Quote Link to comment Share on other sites More sharing options...
woodenduck Posted March 22, 2019 Share Posted March 22, 2019 If you are inside the loop and accessing an attribute which is outside the loop, it won't be updated with the results of the processes inside the loop. Doing it inside an attribute vop like that is a lot more fiddly. I would just run that vex code above, to get your attribute values and then feed that in to the vop to do your various noise calculations. Sorry, but I can't upload any files at the moment. I'll try to put something together this evening. Quote Link to comment Share on other sites More sharing options...
tmdag Posted March 23, 2019 Share Posted March 23, 2019 (edited) just create 'null' object inside the loop (just after 'repeat_begin1') and reference it instead of referencing 'attribcreate1'. you 'attribcreate1' has same value on each iteration because it is not within a loop. Edited March 23, 2019 by tmdag Quote Link to comment Share on other sites More sharing options...
philpappas Posted March 23, 2019 Author Share Posted March 23, 2019 10 hours ago, tmdag said: just create 'null' object inside the loop (just after 'repeat_begin1') and reference it instead of referencing 'attribcreate1'. you 'attribcreate1' has same value on each iteration because it is not within a loop. thanks that fixed it! 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.