kursad Posted February 2, 2011 Share Posted February 2, 2011 Hi I want to be able to find the group with highest or the lowest number of primitives and put all in one group or delete them. Probably I can do with some kind of Python but I was wondering if there is a straight SOP method thanks Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted February 2, 2011 Share Posted February 2, 2011 I'd use the Sort SOP and an expression to order the primitives by the number of primitives listed in the primlist(..) function, and then delete the first primitive of the result. Quote Link to comment Share on other sites More sharing options...
kursad Posted February 2, 2011 Author Share Posted February 2, 2011 I'd use the Sort SOP and an expression to order the primitives by the number of primitives listed in the primlist(..) function, and then delete the first primitive of the result. Hi thanks for the suggestion, but how would I contstruct the primlist funtion since it is asking for a group name? thanks Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted February 2, 2011 Share Posted February 2, 2011 yea, maybe I'm not directing you in the best direction. Can you explain why you need to do this? Maybe if we back up a step there is a better approach. Quote Link to comment Share on other sites More sharing options...
Darric Posted February 2, 2011 Share Posted February 2, 2011 How about something like this? It gets the prim count per group with a foreach to a primitive attribute, and sorts by that attribute, then deletes all primitives that match the prim count of prim 0 of the sorted geometry. *hip attached* Hope that helps! del_highest.hip Quote Link to comment Share on other sites More sharing options...
kursad Posted February 3, 2011 Author Share Posted February 3, 2011 How about something like this? It gets the prim count per group with a foreach to a primitive attribute, and sorts by that attribute, then deletes all primitives that match the prim count of prim 0 of the sorted geometry. *hip attached* Hope that helps! Hey Darric, thank you I think that would do it for me. Initially I was just using connectivity and partition sops to create my groups. Quote Link to comment Share on other sites More sharing options...
Darric Posted February 3, 2011 Share Posted February 3, 2011 However you create your groups is fine, as long as you pass the relevant group mask to the ForEach. Quote Link to comment Share on other sites More sharing options...
resonanz Posted February 4, 2011 Share Posted February 4, 2011 Hi I want to be able to find the group with highest or the lowest number of primitives and put all in one group or delete them. Probably I can do with some kind of Python but I was wondering if there is a straight SOP method thanks I would like to ask if anyone can show me a way how to do this in Python. Is it possible? Thanks Quote Link to comment Share on other sites More sharing options...
petz Posted February 4, 2011 Share Posted February 4, 2011 I would like to ask if anyone can show me a way how to do this in Python. Is it possible? Thanks untested but it should work! geo = hou.pwd().geometry() primGroupList = geo.primGroups() primGroupListSorted = [a for b, a in sorted(zip([len(group.prims()) for group in primGroupList], geo.primGroups()))] group = primGroupListSorted[len(primGroupListSorted) - 1] geo.deletePrims(group.prims()) group.destroy() 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.