Context Options Editor - adding string menu items via python

   60124   4   0
User Avatar
Member
13 posts
Joined: Nov. 2013
Offline
Hi,
I'm currently playing a bit with LOPs trying to use the context options editor to control several switches and variables in a multishot setup.

In order to make that work I wanted to use a python script that allows me to add menu items of a context option.

So lets say the context option is called shot and i wanna add an item with the name "shot_01_name" and value "shot_01"

I was going through the documentation and I saw setContextOption() to change the current option, but I was not able to find a way to add items to the menu?

I guess that's something obvious I'm missing here,
but I would be very thankful if somebody could give me a hint.

Thanks mil,
Alex
User Avatar
Member
31 posts
Joined: Feb. 2014
Offline
Hi - think you've got to use hou.setContextOptionConfig() to add the metadata to define the GUI for a context option.

You can see the formatting for the config string if you add a default "string_menu" context option and query its config with hou.contextOptionConfig("string_menu")

Looks something like this:

{"comment": "", "autovalues": false, "minimum": 0, "menu_items": [["First item", "a"], ["Second item", "b"]], "maximum": 10, "label": "String Menu", "menu_source": "", "max_locked": false, "min_locked": false, "type": "string_menu", "order": 3}

Hope that's helpful
User Avatar
Member
13 posts
Joined: Nov. 2013
Offline
Feeding back in a string formatted like this is working! Thanks a mil!
User Avatar
Member
4 posts
Joined: June 2020
Offline
Hi,

I was wondeirng if it might be possible to go into more detail on how to do this and once the menu is created how to add new options to it?

Thanks,

Alex
User Avatar
Member
6 posts
Joined: March 2024
Offline
thorna100
Hi,

I was wondeirng if it might be possible to go into more detail on how to do this and once the menu is created how to add new options to it?

Thanks,

Alex

As well as to query / edit them, any ideas anyone ?
  • Quick Links