Problem with getting model Parameters

Hi,
I recently made a UI for embedding a model (https://app.shapediver.com/m/3d-printable-cup) and wanted to fetch the model data like in the ShapeDiver “First steps with the API” section. Unfortunately I always get “undefined for” every data index I tried.

Thank you in advance!
Best regards,
Alexander

It looks like your model has not data outputs, make sure you add a data component to your definition.

If you want to get the model parameters, use the api.parameters.updateAsync() function. See more in this CodePen, embedded model is below:

Hi, thank you for your reply!
I didn’t knew that no every model has the ability to get the data. I didn’t make the model and I don’t know much about grasshopper 3D models (I shall only embed the model in a website).
So this means that I can’t get the parameters of this particular model without chancing the model itself?
I would need it to update the slider values after using goBack or goForward…

Thanks again for your kind help!
Best regards,
Alexander

To successfully embed your model with the API access to your website, you need:

  • model ticket as shown in the CodePen above
  • set up domains for embedding.

You can then get parameters and data but the model doesn’t change on ShapeDiver. To get a better idea how the platform works, see following articles:

Keep in mind that embedding is a paid feature but you can get a free trial. Our sales team will be happy to help, contact them via the contact form at www.shapediver.com

Undoing parameter changes via API has been covered in this post:

Hi, thank you for the links!
I already embedded a model in a website (with the ticket from Luca Rua) - here’s the codepen: https://codepen.io/a3x05/pen/wvdrMJP
It’s just a simple UI (that’s not finished at all) where I tested some functions.
The only thing I don’t really know is how to read data from the model. In this case the current diameter etc…
My “job” is just building the UI + making it functional with your API. I don’t use grasshopper or upload models myself.
If I understood right, I can’t get data about this particular model (diameter, color etc…)? Is there maybe any other way to accomplish that?
EDIT: the undo/redo thing works just fine. But the problem is, that I can’t update the slider/input fields because I don’t know how big/wide etc the model is…
Btw: Do you maybe speak German? If so, it would be a lot easier to express myself…

Thank you!
Best regards,
Alexander

The CodePen example in the earlier post shows you how to get model parameters and create custom UI. Have a closer look.

Examples for your model:

  • To get the value of the “Main circle size” parameter use this call:

api.parameters.get({name: "Main circle size"}).data[0].value

  • To get the colour:

api.parameters.get({name: "Colour Swatch"}).data[0].value

Other information about the model can be set in a data output. If what you need isn’t exposed in parameters or data outputs, speak to the author of the Grasshopper definition, ask for the changes, re-upload and update the ticket in your application.

If you struggle with English, I can recommend this translator:

1 Like

Hi, this was exactly what I was looking for! Thank you!

api.parameters.get({name: "Main circle size"}).data[0].value

Now I can finally resume developing!

Thanks! DeepL is a great translator which I used often for other languages.
It’s not a problem for me writing in English, but it’s hard to describe such difficult cases like this one…

Best regards,
Alexander

Ende gut, alles gut :wink:

1 Like