Jump to content

VEX code won't work as expected


iam83

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

Link to comment
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
Link to comment
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 :).

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