Jump to content
iam83

VEX code won't work as expected

Recommended Posts

Hi everyone,

I'm learning VEX in Houdini (as probably everyone here). Recently I tried to recreate a float Attribute in Point Wrangler using VEX.

My attribute was a simple math:

@ptnum / @numpt

When I create this with the Attribute Create node it works fine. But if I do the same in the Point Wrangler it doesn't.

I'm trying to realise why not because "logically" it should work. Obviously, I'm missing something there.

Please see the attached screenshots.

Thanks in advance!

 

HQ_1.PNG

HQ_2.PNG

Share this post


Link to post
Share on other sites

It's because @numpt is an integer in the division. Use the function float() to convert integer to float.

f@ramp = @ptnum / float(@numpt);

But if you want a full ramp from 0 to 1 use this expression

f@ramp = @ptnum / float(@numpt - 1);
Edited by fsimerey

Share this post


Link to post
Share on other sites
1 minute ago, fsimerey said:

It's because @numpt is an integer in the division. Use the function float() to convert integer to float.


f@ramp = @ptnum / float(@numpt);

 

Thanks a lot! God knows, I tried that before too but for some reason it didn't work either. Just tired it now and it does work :). Magic :).

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

×