## Recommended Posts

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

##### Share on other sites

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 by acey195

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