Jump to content

Get group with largest group of points


Annon

Recommended Posts

Hey all,

I have 13 groups and I need to find the value of the group with the largest amount of points.

Group1 = 50

Group2 = 670

Group3 = 127

So in that example I'd need to return 670 as it's the largest number of points.

Which would be the easiest way of doing this? And if that way isn't a VOPSOP way, how would I go about doing this in VOPs as well?

Thanks for your patience, i'm just trying to tie a few gaps in my knowlege together.

Christian

Link to comment
Share on other sites

Personally I'd just do it in a 3 line Python expression and shove it into a detail attribute. You could probably do it using an hscript loop as well but hscript loops can be troublesome. You basically have to just iterate over all the point groups, see how many points are in a group and then keep track of the max. In Python that is something like this:

geo = hou.pwd().inputs()[0].geometry()
points = map(hou.PointGroup.points, geo.pointGroups())
return max(map(len,points))

Also, you can see the attached file.

This kind of problem doesn't really lend itself to a VOPs type solution since you don't really want to be processing every point to find out all this information. If you need the information in a VOP network then you can just use the created attribute inside the network.

max_points_in_group.hip

Link to comment
Share on other sites

Thanks very much!

Yeah I've only done a little bit of non-cg-related Python before, proficcient in MEL, but think I'm going to have to dive in and get it out of the way!

Cheers for that, it's exactly what I needed.

Christian

Link to comment
Share on other sites

  • 2 years later...

Hello there,

Can you help with a similar issue to this? I need to find the name of the largest point group so I can reference its contents. Unfortunately I have no knowledge of applying python to Houdini and I'm quite new to Houdini itself, so this would be very very helpful.

Cheers for your help

Tim

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