Jump to content

How To Get FORVALUE in VEX?


Atom

Recommended Posts

Hi All,

 

I have a Point Wrangle inside a FOREACH. I want to fetch the index of the FOR to include in my calculation.

 

What is the syntax?

 

I have tried...

i = stamp("..","FORVALUE",0);

 

i = ch("../forstamp");

 

i = ch("../FORVALUE");

 

The stamp issues an error in the Wrangle, the other two don't seem to work and always return 0.

 

Link to comment
Share on other sites

stamp() is a hscript expression.

 

On the wrangle node you can edit parameter interface and add a int channel.This is where you will put the hscript expression.

stamp("..", "FORVALUE",0)

 

Then in the vex code you can reference the value by calling the channel.

int i = chi("myintch");

Edited by Alex Lombardi
Link to comment
Share on other sites

Thanks for the different tips. One thing I noticed when I pasted a Relative Copied Reference into the Wrangle code box was that Houdini simply wrapped hScript with those back ticks.

 

I tried this code and it worked!

i = `stamp("..","FORVALUE",0)`;

So I guess you can mix hScript and VEX. I'm not sure if there is a performance hit on doing that but it is nice to know.

Edited by Atom
Link to comment
Share on other sites

be careful about mixing them

by using expression in VEX, you are literally just inserting result of the expression into the code which gets then compiled as VEX

the disadvantages is that VEX compiles only on first frame, so if your expression is time dependent, it may not reevaluate

I would't trust it that much to use stamp expression in that way, go with the spare  parm

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