I am just getting to grips with python in solaris and ejoying it alot. I just had a few questyions about a possible workflow im exploring.
I have made a context option strong menu through a mixture of bits ive found from various sources. Ive ended up with this.
import json hou.setContextOption('layerName', 'layer1') config={"label": "layerName", "type": "string_menu", "autovalues": 1, "menu_items": [["layer1", "value"], ["layer2", "value"], ["layer3", "value"]]} hou.setContextOptionConfig('layerName',json.dumps(config))
This creates me a menu with the 3 options named in the config. The using hou.setContextOption('layerName', 'layer2') for instance i can switch to the 2nd option. All works great.
My question becomes this, how can I add new options. lets say these options are being driven by something in my node graph. I then add a new layer how could that potentially then add a new option in the string_menu? I hoped i could just set a value like layer4 and it would auto create it in the same way it does with the actual context option themslelves but sadly it does not work.
On maybe a more complex note as wel does anyone know how I could populate this string_menu with a list? lets say I get a list of all Null nodes in my scene, I could then have a menu item for each Null?
I was hoping if it was as simple as creating the menu options with setContextOption I could just loop over this. so maybe one answer will solve both.
If anyone can lend me any hand that would be very helpful.
Thanks muchly,
Alex
Senior Lighting TD - Ghost VFX
