Dynamic Value List from Import Text Input in ShapeDiver?

Hi! I’m using a Value List component in Grasshopper to drive some options, but once uploaded to ShapeDiver, the list becomes fixed. Since I’m using Grasshopper for an online shop, I’d like to avoid re-uploading the script every time I need to add new options or links to external data sources.

Is there a way to create a dynamic Value List—maybe by parsing a JSON string from a Text Input in the ShapeDiver editor—so I can update it directly without touching the Grasshopper file?

Thanks!

This is already possible in the App Builder, but as a beta version where you will need to manipulate some JSON objects to create custom parameters. We will add specific components in the near future, but in the meanwhile you can check this tutorial definition and ask your questions here if something is unclear.

250214_DynamicDropdownTutorial.gh (38.8 KB)

Hey Mathieu,
what about when I want to add 2 dynamic parameters?
Currently I am sending

{
  "name": "Frequency",
  "id": "Frequency",
  "type": "StringList",
  "defval": "0",
  "hidden": false,
  "choices": [
    "F2",
    "F3",
    "F4",
    "F5",
    "F6"
  ],
  "value": 0
}

to the the APP component Parameters input. What if I would like 2 or more parameters? I tried

[
  {
    "name": "Frequency",
    "id": "Frequency",
    "type": "StringList",
    "defval": "0",
    "hidden": false,
    "choices": [
      "F2",
      "F3",
      "F4",
      "F5",
      "F6"
    ],
    "value": 0
  },
  {
    "name": "Partition",
    "id": "Partition",
    "type": "StringList",
    "defval": "0",
    "hidden": false,
    "choices": [
      "1/4",
      "1/2",
      "3/4",
      "1/1"
    ],
    "value": 0
  }
]

but I get an error “1. Data conversion failed from Text to AppBuilder parameter definition

Did you try sending a list of strings like this one?

Hi Alexander,

I just tried it and it works - or atleast the APP component in GH does not give me errors. I have another problem:

you can see that when changing “Frequency“ it switches back to the first choice (index 0) can you explain to me what I am doing wrong?

choices logic.gh (51.9 KB)

The problem is explained by the parameter value the GH model outputs after the parameter update:

{
  "value":"0",
  "id":"Frequency",
  "choices":[
    "F2",
    "F3",
    "F4",
    "F5",
    "F6"
  ],
  "defval":"0",
  "name":"Frequency",
  "type":"StringList",
  "hidden":false
}

As you can see, the model outputs value set to ”0”. This will reset the value of the parameter to index 0, which corresponds to F2.

A note about the value property: This property is optional, as opposed to defval (the default value), which is mandatory.

  • If you provide value, it will be used to update the value of the parameter in the app’s UI.
  • If you don’t provide value, the value of the parameter in the app’s UI will stay as is.

That means you have two choices: Either do not output value, or output the correct value.

check app here ShapeDiver App Builder

why parameter Partition seems to be working but Frequency doesnt? I have connected them in the same way. You can see that Partition has value 2 - so it changes while “Frequency” - doesnt

[
    {
        "value": "0",
        "id": "Frequency",
        "choices": [
            "F2",
            "F3",
            "F4",
            "F5",
            "F6"
        ],
        "defval": "0",
        "name": "Frequency",
        "type": "StringList",
        "hidden": false
    },
    {
        "value": "2",
        "id": "Partition",
        "choices": [
            "1/4",
            "1/2",
            "3/4",
            "1/1"
        ],
        "defval": "0",
        "name": "Partition",
        "type": "StringList",
        "hidden": false
    }
]

could it be that I set the same SessionId in Both parameter references?

but it says “This feature is experimental! At the moment, one must make sure to set the sessionID property to “default_appbuilder”.“

There must be a problem in the logic of the GH file such that the value output for the Frequency parameter is always 0.

There is no problem related to the default_appbuilder sessionId, that’s fine.

Thank you for your reply.

I have tried a lot of things and spend considerable time on it but I cannot figure this out.
Can you kindly check what am I doing wrong in my GH script? I treat “Frequency“ same way as “Partition“ but for some reason “Frequency“ doesn’t work

Here is the link to the app https://www.shapediver.com/app/builder/v1/main/latest/?redirect=0&slug=ke1RWVzbdHdNZq5kub7KuMXzZP5ytv
and GH script is attached to this message

choices logic.gh (52.4 KB)

Your definition should only include a single “AppBuilder” text input. It will send a JSON object containing the names and values of all dynamic parameters in the definition:

You can find here a tutorial containing multiple dynamic sliders as a reference: BETA - Tutorial Grasshopper definitions for ShapeDiver

Thanks Mathieu, everything works! I see you released plugin version 1.28 that makes settting this up much easier - will try this :slight_smile: