how to list all the prim attribs in a Ordered Menu?

   8763   5   1
User Avatar
Member
479 posts
Joined: Dec. 2009
Offline
e.g. I have a primitive which has a series of prim attribs: a, b, c, d …

i want to create an otl to visualize a selected attrib from this list.

how to use Hscript of Python script to list out all the attribs of this object in an Ordered Menu?

thanks!
Edited by - Feb. 5, 2011 23:53:28
User Avatar
Member
479 posts
Joined: Dec. 2009
Offline
can anybody kindly help to shed light on this question?

Thanks!
User Avatar
Member
242 posts
Joined: Jan. 2008
Offline
oat
e.g. I have a primitive which has a series of prim attribs: a, b, c, d …

i want to create an otl to visualize a selected attrib from this list.

how to use Hscript of Python script to list out all the attribs of this object in an Ordered Menu?

thanks!

Something like this in the menu script tab will give you that menu.

menu =
attribs = hou.pwd().geometry().primAttribs()

for each in attribs:
menu.append(each.name())
menu.append(each.name())

return menu

If i remember correct orderd menu returns a index number from the list so you will have to extract that in you code via hou.ch.

There are a few examples in the help if you search on asset scripts.

Short of time now but might be able to create an example for you later.
User Avatar
Member
479 posts
Joined: Dec. 2009
Offline
dear mawi, thank you very much!

you suggestion is exactly what I'm looking for!

May i ask another question based on this:

if I “chs” hscript to retrieve the current value of the ordered menu, it will only return the index number of the current item as picked in the ordered menu.

how to retrieve the string that the current index in the ordered menu represents?

e.g. in the ordered menu, 0 means north, 1 means east, 2 means south, and 3 means west. how to retrieve the string of “north” etc instead of their respective index number?


Thanks!
User Avatar
Member
401 posts
Joined:
Offline
You can store the result of menu in hou.session - menu scripts are evaluated three times per redraw - so I've been told.
this is not a science fair.
User Avatar
Member
242 posts
Joined: Jan. 2008
Offline
oat
dear mawi, thank you very much!

you suggestion is exactly what I'm looking for!

May i ask another question based on this:

if I “chs” hscript to retrieve the current value of the ordered menu, it will only return the index number of the current item as picked in the ordered menu.

how to retrieve the string that the current index in the ordered menu represents?

e.g. in the ordered menu, 0 means north, 1 means east, 2 means south, and 3 means west. how to retrieve the string of “north” etc instead of their respective index number?


Thanks!
Dont know if this is the best way…


attribs = hou.pwd().geometry().primAttribs()

index = hou.evalParm(“orderdmenu”)

print attribs.name()
  • Quick Links