Modify parameters based on the Choice parameter within the STRUCT

Everyone,

To simplify data management, I created a Constraint SubParam within the STRUCT attribute’s parameters.

I also want to change the parameters that are overwritten based on its value.

It seems to be working fine, but for some reason, pressing F5 to refresh sometimes reverts it back to the original value.

I created a small test file to isolate the issue, but the same phenomenon occurs.
Does anyone know the cause of this?

Thanks

zero one two three var target = params.getValue('buttonData.selected', 0);

params.setValue(‘buttonData.button.’+ target +‘.name’, 0, params.getValue(‘rename’, 0));

It looks like the struct is reverting to a cached value, or default value. I noticed that the Struct Array is nested inside a struct, is there a reason for this?

If not, I’d recommend separation for these two, it appears to work without the nested structure.

<?xml version="1.0" encoding="UTF-8"?> zero one two three var target = params.getValue('buttonData.selected', 0);

params.setValue(‘button.’+ target +‘.name’, 0, params.getValue(‘rename’, 0));

Thanks for the reply.

I wanted to create a sports coder usable across various sports, and thought creating root params per sport would make API creation and management easier.(Like basketball.team.1.member or soccer.team.1.member…)

After trying various approaches, I reached the same conclusion as you.

It seems that if you modify a Constraint within a structure after the Script has cached it, it doesn’t work properly.

For now, I understand that’s just how it is.

Thanks for testing it.

No probs, there are other ways perhaps. I’ve changed the other ‘struct’ to ‘struct_array’ - you can nest struct arrays within another struct array, the param at the end still gave issues until changed to a ‘string_array’ however.

<?xml version="1.0" encoding="UTF-8"?> zero one two three fed fed 4gryy 3 var target = params.getValue('buttonData.selected', 0);

//params.setValue(‘buttonData.button.’+ target +‘.name’, 0, params.getValue(‘rename’, 0));

params.setValue(‘buttonData.button’, target, params.getValue(‘rename’, 0));


var struct = params.getAllValues(“buttonData”);
var json = params.valueToJson(struct);
var string = JSON.stringify(json, null, 2);
ogscript.debug(string);

This is awesome!

I was just looking for a way to directly manipulate the contents of a struct.

Using getters and setters to handle multiple parameters was a bit slow in execution.

Anyway, thank you!
I’ll try out various things.