Issue: menu item is updated with a new item but parameter interface (
parmTemplateGroup()
) doesn't save it. It doesn't show in UI but via
print()
it shows.Context:
- Karma LOP.
- Created script name:
karmarenderproperties_OnCreated.py
- Created script location:
C:\Program Files\Side Effects Software\Houdini 20.0.653\houdini\scripts\lop
Code I use to add an additional menu item to already existing ones:
# get Karma LOP node node = kwargs['node'] # get all parameters from Karma LOP parm_group = node.parmTemplateGroup() # get 'tonemap' parameter tone_map_param = node.parm('tonemap') # get parameters from 'tonemap' tone_map_template = tone_map_param.parmTemplate() # Update the menu item template with the new item template tone_map_template.setMenuItems(tone_map_template.menuItems() + ('AnimGraphLab',)) tone_map_template.setMenuLabels(tone_map_template.menuLabels() + ('AnimGraphLab',)) print(parm_group.find('tonemap').menuLabels()) # ('No Tonemapping', 'Reinhard', 'Ward', 'Unreal', 'Aces', 'Hable', 'Hable2') # Replace the existing menu template with the updated one parm_group.replace('tonemap', tone_map_template) print(parm_group.find('tonemap').menuLabels()) # ('No Tonemapping', 'Reinhard', 'Ward', 'Unreal', 'Aces', 'Hable', 'Hable2', 'AnimGraphLab') # save Karma LOP parameters layout with new updates node.setParmTemplateGroup(parm_group)
I belive something is with
node.setParmTemplateGroup(parm_group)
since parm_group.replace()
adds a new item.I've tried to create the exact same menu via StringParmTemplate [www.sidefx.com] because
node.parm('tonemap')
type is a String [www.sidefx.com], and it was updated (image below):# get Karma LOP node node = kwargs['node'] # get all parameters from Karma LOP parm_group = node.parmTemplateGroup() menu_template = hou.StringParmTemplate(name='tone_map', label='Tonemap', num_components=1, menu_items=('off', 'ward', 'unreal', 'aces', 'eminem'), menu_labels=('no tonemap', 'ward', 'unreal', 'aces', 'Eminem'), ) # insert menu items as a very first paramter param_to_insert_before = parm_group.find("quicksetup") parm_group.insertBefore(param_to_insert_before, menu_template) desired_label = "AnimGraphLab" existing_labels = menu_template.menuLabels() if desired_label not in existing_labels: new_menu_items = menu_template.menuItems() + (desired_label,) new_menu_labels = existing_labels + (desired_label,) # Update the menu template menu_template.setMenuItems(new_menu_items) menu_template.setMenuLabels(new_menu_labels) # Update the parameter template group with the modified menu parm_group.replace('tone_map', menu_template) # save Karma LOP parameters layout with new updates node.setParmTemplateGroup(parm_group)
What am I doing wrong?
Thank you.