dreamagrery2 Posted August 29, 2017 Share Posted August 29, 2017 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! Quote Link to comment Share on other sites More sharing options...
Sepu Posted August 29, 2017 Share Posted August 29, 2017 (edited) you could either use the group_range SOP or use the module function even % 2 = 0 odd % 2 = 1 Edited August 29, 2017 by Sepu Quote Link to comment Share on other sites More sharing options...
Noobini Posted August 30, 2017 Share Posted August 30, 2017 (edited) 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 August 30, 2017 by Noobini Quote Link to comment Share on other sites More sharing options...
dreamagrery2 Posted August 30, 2017 Author Share Posted August 30, 2017 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! Quote Link to comment Share on other sites More sharing options...
Sepu Posted August 30, 2017 Share Posted August 30, 2017 (edited) 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 August 30, 2017 by Sepu Quote Link to comment Share on other sites More sharing options...
Noobini Posted August 30, 2017 Share Posted August 30, 2017 (edited) 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 August 30, 2017 by Noobini Quote Link to comment Share on other sites More sharing options...
dreamagrery2 Posted August 30, 2017 Author Share Posted August 30, 2017 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! Quote Link to comment Share on other sites More sharing options...
dreamagrery2 Posted August 30, 2017 Author Share Posted August 30, 2017 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!! Quote Link to comment Share on other sites More sharing options...
Noobini Posted August 30, 2017 Share Posted August 30, 2017 (edited) 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 August 30, 2017 by Noobini 1 Quote Link to comment Share on other sites More sharing options...
Noobini Posted August 30, 2017 Share Posted August 30, 2017 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. 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.