Jump to content

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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;
    }

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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);

Share this post


Link to post
Share on other sites

Not sure I understand what you're trying to do. Can you post a hip file? 

 

Share this post


Link to post
Share on other sites

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. 

 

Share this post


Link to post
Share on other sites
Posted (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 by tmdag

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×