juleslin Posted August 22, 2018 Share Posted August 22, 2018 Hi all, I am a MAX user for 10 years, able to write some very simple maxscript. Just started to explore Houdini a few months ago and trying to learn VEX. I hope someone could show me a very simple VEX sample to help me solve the question. I created a grid, applied a scatter node to generate 100 points on the surface. And I would like to add different values (5 | 10 | 20) to these point's attribute (i@prob) by using attribute wrangler "for loop". In max, I would do something like this: for n in 1 to $.count do ( $[n].scale = [2,2,2] ) Sorry that the question is too "fundamental"... Quote Link to comment Share on other sites More sharing options...
acey195 Posted August 22, 2018 Share Posted August 22, 2018 (edited) for static values you can just use a "attribute create" node. for wrangles, if they run over "Points" that means it is already looping over all points, so the following should be enough: v@prob = set(5, 10, 20); // if you want to store the data as a vector or you could do, if you want to pick an integer randomly from your list: int probAr[] = {5, 10, 20}; int index = int(rint(rand(@ptnum) * 2)); //rint is for rounding the value to the nearest integer i@prob = probAr[index]; // you could even put this entire code in one line if you would like, like this: i@prob = int({5, 10, 20}[int(rint(rand(@ptnum) * 2))]); Edited August 22, 2018 by acey195 Quote Link to comment Share on other sites More sharing options...
juleslin Posted September 6, 2018 Author Share Posted September 6, 2018 Thank you Acey195!! That helped a lot! 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.