Python FBX: Getting a list of items from a group drop down

   2089   4   1
User Avatar
Member
6 posts
Joined: Dec. 2019
Offline
Hello,
I have imported a fbx file as a simple geo (File > Import > Geo ).
Then attached a bound node so that I can choose an object from the group list to bound ( using parm().eval()).

I can see from the group dropdown list that there are multiple actors to choose from ( e.g @name=InstancedFoliageActor_0/0 )
I want to store all items present in this drop as a list.

What's the python command to make that happen ?

I have tried using this snippet but I'm getting an empty list.

import hou

node = hou.selectedNodes()[0]
groups = [g.name() for g in node.geometry().primGroups()]
print groups

Attached a screen grab.
I have written a python shelf tool to get my work done another way but I'm curious how to do the above.

Thanks for any help,
b

Attachments:
houdini_python_group_list.JPG (141.1 KB)

User Avatar
Member
9247 posts
Joined: July 2007
Online
those are not explicit groups, you can middle click on the node and see there are no groups
those are automatically generated groups from the values of name attribute, hence they start with @name=

to get all values of the name attribute and generate such ad-hoc groups in python you can do
import hou

node = hou.selectedNodes()[0]
name_attrib = node.geometry().findPrimAttrib("name")
if name_attrib:
    names = name_attrib.strings()   
    name_groups = [ '@name=' + name for name in names ]
    print(name_groups)
Edited by tamte - Feb. 23, 2022 11:24:13
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
6 posts
Joined: Dec. 2019
Offline
tamte
those are not explicit groups, you can middle click on the node and see there are no groups
those are automatically generated groups from the values of name attribute, hence they start with @name=

Thank you for the clarification Tomas.
This works as described by you on the file node but not on the bounds node.

What if I want to query the Bounds node and perhaps even change / set it to a certain string value. Am I then forced to query the file node instead ?
Running the code on the Bounds node gives me nothing obviously since the data is coming from up - stream.

Pic attached.

I'm new to python scripting in Houdini so I Appreciate your help here.

Thanks,
b
Edited by behram_patel - Feb. 23, 2022 13:27:27

Attachments:
houdini_python_group_list01.JPG (215.5 KB)

User Avatar
Member
9247 posts
Joined: July 2007
Online
behram_patel
This works as described by you on the file node but not on the bounds node.
again, middle click on the node to see what attributes or groups are available
the bounds node will not keep your input geo, therefore no attributes or groups, it will create a new bounding box geo, so if you are getting geometry of the bounds1 node you will not get any attributes (just P) or groups

so yes, if you want original geo, you either get the input geo of the bound1 node (node.inputGeometry(0)) so you dont need to explicitly know whats connected to it
or you can get the content of that menu directly if that's more helpful (parm.menuItems() or parm.menuLabels()) which is also built internally by looking at the input geo
Edited by tamte - Feb. 23, 2022 13:50:57
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
6 posts
Joined: Dec. 2019
Offline
tamte
or you can get the content of that menu directly if that's more helpful (parm.menuItems() or parm.menuLabels())

This is exactly what I was looking for !

for e.g
node = hou.selectedNodes()[0] 
group_list = node.parm('group').menuItems()

Thank you so much Tomas. I have learned something new and valuable today.

Cheers,
b
  • Quick Links