Jump to content

just delete a freaking point


kleer001

Recommended Posts

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()]])

          
 

Link to comment
Share on other sites

**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 )
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...