Farmfield Posted January 26, 2017 Share Posted January 26, 2017 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 Quote Link to comment Share on other sites More sharing options...
f1480187 Posted January 27, 2017 Share Posted January 27, 2017 It's easy, if you use HOM instead of Expression: import random n = 100 bottom = [] rest = [] for p in hou.pwd().inputs()[0].geometry().points(): if abs(p.position()[1]) < 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 Quote Link to comment Share on other sites More sharing options...
Farmfield Posted January 30, 2017 Author Share Posted January 30, 2017 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. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted January 31, 2017 Share Posted January 31, 2017 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()[0].geometry().points(): if abs(p.position()[1]) < 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 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.