How change "type properties" with python for DA

   2830   1   0
User Avatar
Member
11 posts
Joined: Nov. 2013
Offline
How do I change parameters in “edit operator type properties” with python for a digital asset ?

Hello,

In fact, I would like to change with python the menu items (token and label) for a procedural “ordered menu”.

Thanks
User Avatar
Member
11 posts
Joined: Nov. 2013
Offline
So ok, I can have token and label of my menu (already created) :

>>>a = hou.parm('/obj/characters/menu_parm')
>>>a.menuItems()
('0', ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’)
>>>a.menuLabels()
('Zero','One', ‘Two’, ‘Three’, ‘Four’, ‘Five’, ‘Six’)
In the doc help I found this :
Parameter menu scripts

You can use Python to generate dynamic parameter menus. The script must return a list of strings, where the even strings are internal names, and the odd strings are labels, for example . (This strange design is an unfortunate analogy to the output of the equivalent Hscript.)

If a Python menu script contains only one line, Houdini evaluates it as a Python expression. If it contains multiple lines, Houdini evaluates it as a function body. This behavior is the same as for Python parameter expressions.

For example, to generate a menu of Object-level digital assets using Python:
result =
for tool in hou.shelves.tools().values():
node_type_name = tool.toolMenuOpType(hou.paneTabType.NetworkEditor)
if (node_type_name.startswith(“Object/”) and
‘Digital Assets’ in tool.toolMenuLocations()):
result.append(tool.name())
result.append(tool.label())
return result

In an asset, you can put the code that generates the menu into a function in the asset’s PythonModule section (e.g. a generateMenu function) and call that function in the menu script hou.pwd().hdaModule().generateMenu()
The problem is that I understand not too code provided by the documentation and how to adapt in my case :? create a procedural “ordered menu” with :
menu Items = ('0', ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’)
menu Labels 'Zero','One', ‘Two’, ‘Three’, ‘Four’, ‘Five’, ‘Six’) .

Indeed when I type the code of the doc in the tab menu script for my menu ordered it I created a menu with 1 single input ‘characters’ (the name of my digital asset…)
  • Quick Links