kleer001 Posted May 26, 2015 Share Posted May 26, 2015 Hitting my head against the simplest python syntax. here's my code: What am I doing wrong?! What little thing am I missing? import random node = hou.pwd() geom = node.geometry() for point in geom.points(): rando = random.random() if rando < 0.5: geom.deletePoints([geom.iterPoints()[point.number()]]) Quote Link to comment Share on other sites More sharing options...
kleer001 Posted May 26, 2015 Author Share Posted May 26, 2015 **SOLVED** The trick is to create a list before the loop, append points to that list, then delete the contents after the loop. Or just do it in a wrangle SOP as that's faster. import random node = hou.pwd() geom = node.geometry() ptstodelete = [] for point in geom.points(): rando = random.random() if rando < 0.5 : ptstodelete.append( point ) geom.deletePoints( ptstodelete ) 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.