Dynamic Option field

Hi,

I’m looking to build a dynamic option input list.
The user in this case chooses a material, and then gets the names and the finally gets it’s strength.

The values comes from a spreadsheet that are available in the functions that call based on the user choice.

How do I get the input of the optionsfield from the user to get the variable to call the next function. How do I do this?

I tried this but, it returns an object and not sure of the rest.

def get_material_options(params, **kwargs):
return get_class_values(params.material_group)

class Parametrization(ViktorParametrization):
material_group = OptionField(‘Material group’, options=get_material_types())
material_type = OptionField(‘Material’, options=get_material_options)

Thanks
David

Hi there,

Welcome to the forum, thanks for posting!

As far as I can see your snippet should work fine. That is, depending on where the get_class_values() function lives. Could you provide a little more detail on what that function does and where it is housed? I suspect the problem lies there.

Hi,

For some reason it didn’t work before, but is working now.

I guess my issue was then it is in a table or array.

For eg the return (params.tab1.array.material_group) doesn’t seem to work.