Problem with OptionField

I am trying to add the following OptionField to my parametrization:

param3Options = [OptionListElement('0', 'Selfweight'), OptionListElement('1', 'Point Load'), OptionListElement('2', 'Line Load'), OptionListElement('3', 'All')]
param3 = OptionField('LoadCase', name='ShapeDiverParams.6cc906cf-8cf3-4e3f-a185-affbf6e4fb55', options=param3Options, default='1')

As soon as I add this to my Parametrization I get the following error:

2023-10-19 15:39:02.902 ERROR   : 'list' object has no attribute '_generate_entity_type'
2023-10-19 15:39:02.902 ERROR   : Error in app definition, app not reloaded

Is there some problem in my code?

Hi Alex,
The problem is that each attribute under the parametrization is assumed to be a field. The list containing the options is not a field and this trips the generation of the input side. The error is a bit cryptic unfortunately.

You can solve this by prepending the attribute with an underscore: _param3Options in your case, or moving the variable out of the class.

relevant part in the docs: SDK Reference - Parametrization | VIKTOR Documentation

hope this helps,
Matthijs

2 Likes

Many thanks @matthijs, got it!

1 Like