Atom Posted August 2, 2015 Share Posted August 2, 2015 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. Quote Link to comment Share on other sites More sharing options...
Alex Lombardi Posted August 2, 2015 Share Posted August 2, 2015 (edited) 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 August 2, 2015 by Alex Lombardi Quote Link to comment Share on other sites More sharing options...
Storm Keeper Posted August 2, 2015 Share Posted August 2, 2015 The way to do this is to create a spare parameter with any name on your Wrangle node (for example, call it "idx"), set an expression on it ( stamp("..","FORVALUE",) ), and reference it in your VEX code as follows: i = ch("idx"); Quote Link to comment Share on other sites More sharing options...
Atom Posted August 2, 2015 Author Share Posted August 2, 2015 (edited) 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 August 2, 2015 by Atom Quote Link to comment Share on other sites More sharing options...
Alex Lombardi Posted August 2, 2015 Share Posted August 2, 2015 If you run the performance monitor you will see a slight difference in favor of the ch reference method...not much though Quote Link to comment Share on other sites More sharing options...
anim Posted August 2, 2015 Share Posted August 2, 2015 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 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.