Jump to content
Sign in to follow this  
dreamagrery2

Even Number Delete

Recommended Posts

Hi, 

I have a list of groups that was generated by a copy SOP. The listed was created as follows: pointgroup_0_2, pointgroup_0_3, pointgroup_0_4, and so on. 

How do I delete only the even number groups? Please help. 

Advanced thanks!

Share this post


Link to post
Share on other sites

you could either use the group_range SOP or use the module function 

even % 2 = 0

odd % 2 = 1

 

Edited by Sepu

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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!

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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!

Share this post


Link to post
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!!

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×