Jump to content

Even Number Delete


dreamagrery2

Recommended Posts

here you are...

(note: you said delete the groups...NOT the actual points themselves, so don't expect to see the points disappearing, if you middleclick on the python node, you'd see the EVEN groups are gone)

ahhh...what the hell, I've updated the file so you can delete the points as well if you wish..it was a good exercise for me to go thru (1st time doing Python....ever !!!)

 

DeleteEvenGroups.hipnc

Edited by Noobini
Link to comment
Share on other sites

14 hours ago, Noobini said:

here you are...

(note: you said delete the groups...NOT the actual points themselves, so don't expect to see the points disappearing, if you middleclick on the python node, you'd see the EVEN groups are gone)

ahhh...what the hell, I've updated the file so you can delete the points as well if you wish..it was a good exercise for me to go thru (1st time doing Python....ever !!!)

 

DeleteEvenGroups.hipnc

Thanks @

  • Illusionist. I really appreciate your help and this will help me in the future. It seems that this approach works with points. Might you have a practical approach for this with groups alone-- where the copy SOP creates the groups and you delete only even number groups? Thanks in advance!
Link to comment
Share on other sites

you can do is again with the modulus function here is an example. you should show up a screenshot how your groups are builds.
Check your spreadsheet when you open the file, I created a group for each sphere with the partition SOP then I use the enumerate SOP to give some some kind of ID to the groups then in the wrangle I just do  
 

if(i@index % 2) {
    i@idx = 1;
}

to check odd and even, after that in the delete sop you do 

@idx==0

to delete your even Groups/Prims.

deletebyModulus.hip

Edited by Sepu
Link to comment
Share on other sites

it's doing exactly what you want: deleting (point) groups, not the points themselves. THIS IS WHAT YOU ASKED FOR.

Then i even gave you the option to delete the actual points in case that was your real intention....what more do i have to do ?

Why point groups ? cos you said your groups are pointgroup_xyz

Edited by Noobini
Link to comment
Share on other sites

2 minutes ago, Noobini said:

it's doing exactly what you want: deleting (point) groups, not the points themselves. THIS IS WHAT YOU ASKED FOR.

Then i even gave you the option to delete the actual points in case that was your real intention....what more do i have to do ?

You're right! I just couldn't get my head around it! This is a way different approach than what I am used to. Thank you!

Link to comment
Share on other sites

1 hour ago, Sepu said:

you can do is again with the modulus function here is an example. you should show up a screenshot how your groups are builds.
Check your spreadsheet when you open the file, I created a group for each sphere with the partition SOP then I use the enumerate SOP to give some some kind of ID to the groups then in the wrangle I just do  
 


if(i@index % 2) {
    i@idx = 1;
}

to check odd and even, after that in the delete sop you do 


@idx==0

to delete your even Groups.

deletebyModulus.hip

This is perfect. It seems much easier to understand. Thank you!!

Link to comment
Share on other sites

i don't mean to be rude since i have much less experience than alot of ppl here...but i think using idx approach is flawed. if i manually select some points, assign them to pointgroup_0, then again manually select some points assign them to pointgroup_1....rinse, repeat.....(think clustering)

Now i want to delete the pointgroup_ that are even numbered.....it has nothing to do with point idx...it's simply the last digit of the groupnames.

(i've yet to open up sepu's file to dissect tho, will do later...so that could be perfect for all i know :) )

Edited by Noobini
  • Like 1
Link to comment
Share on other sites

here's one that deletes any group that evenly named. (ie. your groups can be of points, edges or prims)
 

node = hou.pwd()
geo = node.geometry()

# Add code to modify contents of geo.
# Use drop down menu to select examples.

myPgroups = geo.pointGroups()
myEgroups = geo.edgeGroups()
myPrimgroups = geo.primGroups()

# make up your own combination here for whatever you want to check
checkgroups = myPgroups + myEgroups + myPrimgroups

for group in checkgroups:
    lastchar = int(group.name()[-1])
    if lastchar % 2 == 0:
    
        # remove the '#' from next line if you DO want the points deleted as well
        #geo.deletePoints(group.points())
        
        # delete the group
        group.destroy()

I stress again, it deletes groups....NOT actually deleting points/edges/prims.

This is because the spec says: "How do I delete only the even number groups? "

If your intention is to delete actual geometry.....the points/edges/prims/copied geo....then be clear in the spec.

  • Like 1
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...