Setting Input variables

In the Parametrization class I would like to re-use user input from a TextField for another input which depends on this input. For example in a OptionField I want the user to select from a previous provided input.

Or I want the input to be used later as a value inside a Table. Is this even possible? I just experimenting with Viktor for the 1st time and find it difficult to lose the flexibility I normally have.

Another example: how can I generate a dynamic name, i.e the first TextField in a dynamicarray is “myselection_”+“01”, the next time I want to select an option its “myselection_”+“02” etc. Normally I would just write a loop with a running variable i to set the number, but I have no clue where to start from here.

Thanks!

Hi @MLUY,

Great to see you playing with Viktor for the first time! And nice to see you’ve found the forum for your questions.

Regarding the first question; this is achieved using a Callback Function. The callback function has access to the params, and could include your TextFields value; such as:

def get_options(params, **kwargs):
    """Get the options based on other fields"""
    output = ["Standard Item"]
    if params.text_input:
        output.append(params.text_input)
    return output

Regarding the second question; We have designed the DynamicArray in a way that it shows the row number in the left corner. To make it more visually appealing to the user, we believe it’s better to have the variable names as readable as possible. As a developer, you can use normal iteration tools to have full access to your DynamicArray. I’m curious on what are you trying to achieve by adding the numbers, could you elaborate on that?

Hopefully that helps you out!

Rick

Thanks Rik
I made some small errors its working now. The question on the numbers was just because I was trying to understand some mechanics, nothing special. I am getting to understand Viktor a bit now and I must say that once you play around with it it is an efficient system.
Thanks again
Michiel

1 Like