python - list primitives form group

   6145   3   1
User Avatar
Member
345 posts
Joined:
Online
I'm trying to get the tuple or string of primitives associected with the given primitive group. I can list groups form the given node (hscript unfortuanatelly)


groupstring = hou.hscriptExpression(“primgrouplist(\”/obj/geo1/group2\“)”)


but how can I get the primitives, I can't find any relevant functions in help.


PS. I must be dumb, I find hou help very difficult to work with. Or maybe I'm too much used to to hscript/expression help where everything was on one page.

Anyway, help much appreciated.


Cheers,
kuba
User Avatar
Member
1906 posts
Joined: Nov. 2006
Offline
Unfortunately, HOM doesn't currently have any sort of geometry group support so you are forced to use hou.hscriptExpression()

When dealing with Primitives for example, as you indicated you need to do something involving primgrouplist and primlist to get groups and numbers of the primitives in the necessary groups. You can then use those prim numbers to help grab hou.Prim objects from the geometry by using hou.SopNode.geometry().prims().
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
1906 posts
Joined: Nov. 2006
Offline
More of just a general thing than perhaps this problem, but I spent a few minutes combining some of my own bits of code and coming up with some simple classes that should make working with existing groups easier and more Python like until there is actual HOM support for them.

If you import the attached file into a Houdini session, you gain access to 4 new functions that are bound to the hou.Geometry glass. These new functions return a list of objects that correspond to point and primitive groups on the geometry. These class objects allow you to get info such as the group name, the node it corresponds to, the list of entity numbers and a list of hou.Point or hou.Prim objects associated with the group.

Nothing too complex or special but it may be of some use to people.

Attachments:
grouputils.tar.gz (10.0 KB)

Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
1390 posts
Joined: July 2005
Offline
Ah, thanks graham, very convenient!

cheers,
skk.
  • Quick Links