## Recommended Posts

This just gotta have a simple solution, just couldn't think of a straightforward way to solve it. I'm looking for a division independent way to group N amount of random points from the bottom (P.y == 0) and an equal amount of random points from the rest (@P.y > 0). And sure, you can solve this several ways, using a couple of SOPs, but I'm looking for something like a single expression in a group- or wrangle SOP, if that's even possible.

The only one-node-solution I can think of is splitting the bottom and other points into arrays in a wrangle SOP and choose N amount of points from each - but I instinctively feel there's gotta be a really simple solution I'm missing, it's my default mode, missing the obvious... grid.hiplc

##### Share on other sites

It's easy, if you use HOM instead of Expression:

```import random

n = 100

bottom = []
rest = []
for p in hou.pwd().inputs().geometry().points():
if abs(p.position()) < 1e-6:
bottom.append(p.number())
else:
rest.append(p.number())

random.seed(12345)
random.shuffle(bottom)
random.shuffle(rest)

return ' '.join(map(str, bottom[:n] + rest[:n]))```

Result: complex_pattern.hipnc

##### Share on other sites

Aah, I explained this badly, I want two groups, one with N number random points at Y = 0 and one with N random points out of the remaining points.

And I really gotta do a Python refresher, haven't gotten into HOM at all.

##### Share on other sites

It's mostly the same, you need to add unselected points to the rest list before sorting it randomly:

```import random

n = 100

bottom = []
rest = []
for p in hou.pwd().inputs().geometry().points():
if abs(p.position()) < 1e-6:
bottom.append(p.number())
else:
rest.append(p.number())

random.seed(12345)
random.shuffle(bottom)

rest += bottom[n:]
random.shuffle(rest)

return ' '.join(map(str, bottom[:n] + rest[:n]))
```

• 1

## Create an account

Register a new account