Jump to content

Deleting the group woth the highest number of primitives?


kursad

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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