Update ShapeDiver TextfileInput component via API

Hi,

I have a GH definition generating geometry out of JSON properties. The JSON file is read into the GH definition using ShapeDiver TextfileInput component.
The total number of properties stored in the input JSON file may vary. But there is a minimun set of required properties in each JSON file from which the actual geometry is generated. The other possibly existing properties store additional data but are not relevant to the logic of building the geometry inside the GH definition.

On the client-side I read in the JSON and extract distinct properties. I am using those to create input fields for each of the distinct properties found in the uploaded JSON. The total number of input fields on the web page may therefore vary depending on the JSON file (all fields share the same minimum amount of required properties).

As I do not know in advance how many input fields I will need to have, I cannot simply add ShapeDiver TextInput components to my GH definition to control the parameter values.

Is there a way to update the JSON file on the fly from the client-side using e.g. api.parameters.updateAsync() method?
Or would you propose an alterative implementation?

Thanks,
Eduard

I’m not sure I quite understand your use case so please correct me if I’m wrong. If you read the whole JSON with the SDTextInputFile component you get all available properties which you can then parse without the need for the text inputs with SDTextInput. SDJSONAccess throws an error if it misses a property but the rest of your model logic will work fine with given parameter values from the JSON file.

Hi @pavol,

your example covers just the first half of my GH definition. I am creating the model using the properties gathered from the uploaded JSON file (as in your example).
But I also want the user to be able to change the value of certain properties via his web browser’s UI. Thus I need to feed back the overwritten property values from the initial JSON file so the GH solver is triggered again and updates the geometry.
I managed to achieve this by using the ShapeDiver TextInput in conjunction with Stream Filter.
Issue resolved - thanks!