Information flow from GH to configurator

Hi, say a configurator has an item that when displayed in the gui when you select it has a title, description, image and price is it possible to define in grasshopper so the information flows through the syem?
Also is there a recommended system for handling orders?

I am not sure I understand exactly the flow of information you want to implement. However, you can pretty much send and receive data to and from the model in any way you want

Sending data to the definition:

  1. Add ShapeDiverTextInput parameters to the Grasshopper definition.
  2. Send text to the online model using the api.parameters.updateAsync() function of the API. The text can be a JSON object which you can parse and access using the JSON components. Or you can simply send strings and numbers to use in your definition.

Extracting data from the definition:

  1. Add ShapeDiverDataOutput components to the definition. You can output text, numbers and some other Grasshopper types. The output will preserve the tree structure.
  2. Retrieve the data from the online model using the api.scene.getData() function of the API.

This documentation article contains a simple example of sending parameters and extracting data from a definition.

1 Like

We managed to update parameters and get Data from our model, but are struggling with the following:

How can I run a getData or any other api function directly after the viewer has initialized. We are trying set the initial view using; and already displaying the data from the GrasshopperDataOutputs.

We can only find examples on how to do this after an interaction like pressing a button, but never how to have it there from the start.

We also couldn’t find which events there are for an eventlistener to subscribe to. I think that part is still missing in the API documentation.

There are different event types for each interface of the API (api.scene, api.parameters, api.exports, etc…). You can find the list of events for the scene interface here.

In your case, what you need is to wait for the event that tells you that the scene is loaded. There are two events that can be used: SUBSCENE_PUBLISHED or VISIBILITY_ON (I usually use the latter).

The code then looks like this:

api.scene.addEventListener(api.scene.EVENTTYPE.VISIBILITY_ON, function() {
  // now it's safe to read the model parameters
  var data = api.scene.getData();

This concept is explained in the following tutorial, for example:

You can also find several API use cases in our CodePen account:

We are in the process of migrating the example of our API documentation to CodePen and building a database of fiddles. Developers tend to like starting from code examples better than reading lenghty documentation articles, and we are slowly adapting the support materials accordingly.