Help! creating a group selection menu...

   7563   5   1
User Avatar
Member
20 posts
Joined: April 2012
Offline
Hi everyone, I've been working on an tool for the Orbolt store and I want to add an option to select a group to use my tool on.

I've figured out that it can just be a string field and that someone can enter a group name and it'll work fine (which is what I have now and what I will use if I can't get this to work…). However most tools in Houdini also have a nice selection menu, on the right of the field, with the groups listed in them. I'd like to have that on my tools as well.

I did figure out I need a “Toggle” menu for that, but that alone isn't enough.

I did find a script in the help file that supposedly needs to go there to make it work, however it doesn't seem to work (I copy/pasted it in my asset and it still doesn't list anything…).
I've been looking in the help file for other help besides those few examples that don't seem to work, but there isn't anything I could find. I usually don't have much trouble with scripting stuff, but most of this just looks like gibberish to me xD

A bit off topic, and I don't want to sound negative (I love Houdini, for the most part ), but I'm kinda surprised that there isn't a preset (in “create parameters”) option for this. I mean, we got 20 options for vectors which are all basically the same, but not a preset for something that's basically on every single surface tool in Houdini… And no easy to find documentation on how to make it either.

Anyway, I would really appreciate help with this and I hope in the future there will be some presets for some of the basic dynamic menus that are often seen on tools (similar to how you now have a simple drop down menu for what an “Operator list” should list).
User Avatar
Member
2624 posts
Joined: Aug. 2006
Offline
I've figured out that it can just be a string field and that someone can enter a group name and it'll work fine (which is what I have now and what I will use if I can't get this to work…). However most tools in Houdini also have a nice selection menu, on the right of the field, with the groups listed in them. I'd like to have that on my tools as well.

Can you not open up the tool and have a look how its implemented ?.
I will add one other thing that I come across all to often in production with otls and thats tools that try to act as a swiss army knife, its better to keep the otl simple and let it do one thing rather than 10.
Without even knowing what your tool is I would be more inclined to let the user feed in the geometry or points and then the tool acts on that.

Rob
Gone fishing
User Avatar
Member
20 posts
Joined: April 2012
Offline
I'm trying to make “the tool”, opening it up won't help me… I've been looking at other tools, but their group selection lists seem to be broken as well. Or in case of the default build in tools, they don't expose how they do it (it's greyed out and there's nothing there).

Also, I'm trying to make a simple (but powerful) otl here… A group selection list isn't a rare thing on Houdini tools, in fact, the majority of tools allows a user to define a group(s) that the tool should operate on.

I'm just going to guess that we have a miscommunication here.

btw, I did try to promote one of the nodes inside my tool (like take a group parameter from one of the nodes inside and put that on the parameter list), but they also don't work (or at least they're not listing any groups…).


Edit: According to the help this is the Hscript that should do the trick:

result = “”
foreach groupname ( pointgroupmask(“.” + opinput(“.”, 0), “*”) )
result = $result + “ $groupname ” + `toupper($groupname)`
end
echo $result

It doesn't do anything for me though.
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
try this (make sure to switch your scripting to python and to provide a proper node path). This is assuming that you want primGroups. if not, replace with pointGroups() or edgeGroups()


geo = hou.node(“pathToANodeThatHasYourGroups”).geometry()

groups =

for group in geo.primGroups():

groupName = group.name()
groups +=

return groups

-G
User Avatar
Member
20 posts
Joined: April 2012
Offline
Thanks! Now I'm getting somewhere

I was already looking at python as well, however I couldn't cobble something together from the examples I found (probably because I'm not quite familiar with python and the Houdini classes xD).

Anyway, I replaced the first line with this:

geo = hou.pwd().geometry()

Which seems to work as well

I think my tool will work with both primitive groups and point groups though (I'll do some testing to make sure), but I think I'll be able to figure out how to add those as well if I need them.

Edit: Looks like “Blast”-ing point and edge groups makes a bit of a mess xD So I'll stick to primitive groups

Anyway, thanks again I'm sure this will be of great help with any future tools I'll make.
User Avatar
Member
1 posts
Joined: Jan. 2018
Offline
Should anyone be looking for an answer to this question here is a simple solution:

# Get the currently selected group type
geometryType = kwargs["node"].parmTuple( "grouptype" )

# Get the value (points, edges, prims, etc)
for tuple in geometryType:
  type = tuple.rawValue()

menu = []
i = 0
# Get the current node
node = kwargs.get( "node", None )

# Select the groups to work with based
# on the selected group type
if node:
  if type == "points" ||:
    groups = node.geometry().pointGroups()
  elif type == "edge":
    groups = node.geometry().edgeGroups()
  elif type == "prims":
    groups = node.geometry().primGroups()
  else:
    return menu
  
  # Iterate through the groups and
  # add each name to the menu
  for group in groups:
    gName = group.name()
    menu.extend( [str(i), gName] )
    i += 1

return menu

Attachments:
menu-script.png (98.5 KB)

  • Quick Links