Custom Parameter Dynamic Default Value

Hi,

I created a custom parameter of type MaterialParameter that extends GH_Param<GH_String>. The new parameter implements a dynamic dropdown based on an input json. However, I don’t know how to actually connect the user selected string in the dropdown (GUI side) with the value of the parameter (volatile data). currently the component only runs if an external string/textbox is plugged in…

I think the problem is that although pManager.AddParameter(new MaterialParamer()) registers a material parameter, DA.GetData does not track which string is currently selected in the dropdown. I tried to add the selected string as volatile data, but that didn’t work – what should I do instead so the string variable Material that I created in MaterialParameter is read when DA.GetData is called?


responding to my own question, hopefully helpful for others having similar issues:

you need to register a callback, so that when the item is clicked in the dropdown, the value is also added as volatile data for that parameter