[WEBINAR] Day 2 Challenge (07/05/2020)

Hi Edwin! I’m trying to create something very similar like this example from the documentation. But I’m finding it difficult to create the json syntax within the grasshopper that corresponds to this java script. My main difficulty is how to associate a color and thickness for each element of my data tree.

https://jsfiddle.net/ShapeDiver/13h7sjzL/

This is an example in documentation “Tutorial: User interface with clickable 3d objects”

:pray: Could you share the grasshopper file for this tutorial? :pray:

This way it would be easier to understand how I can create scripts with the json components of the shapediver.

This is the model I am creating for a client. For each hexagon selected, the user will be able to choose the color and thickness. I also need the code to inform which hexagons were selected so that it can be manufactured with the chosen thickness and color.

I’m afraid the Grasshopper file for this tutorial won’t help you, because each sphere is in a separate ShapeDiverDisplayGeometry component. I organized it this way to make the tutorial as easy to read as possible.

clickable_spheres.gh (54.0 KB)

However, I think in your case, all hexagons are contained in a single ShapeDiverDisplayGeometry, in different tree branches. This is of course the best solution if you have a variable number of hexagons in the model. In that case, you will find all hexagons in a single asset of the viewer, but in different items of the content array. In other words, what you need to change is probably not your Grasshopper model but rather the javascript code.

I will adapt the spheres example to your case and get back to you in the next few days.

1 Like

Hi Mathieu! From what I saw of the file there is no JSON component of the shapediver inside the file. So the API is directly changing the view through the sliders?

In my case, I need to receive the information from the site to:
1 - extrude the polygons with the chosen thickness,
2 - paint the color of each hexagon clicked,
3 - show only the chosen hexagons.

I believe that javascript would look something like this:

var hexa = {
  hexagons: [
    {
      color: [235, 245, 235],
      center: [0.0, 45.05, 100.8],
      thickness: 15,
        appear: true
    },
    {
      color: [123, 135, 235],
      center: [0.0, 281.25, 141.7],
      thickness: 18,
        appear: false
    }
  ]
};

The hexagon grid is just a reference for the user to “paint” the wall.

The variable “appear” will be used with a control to assemble a panel with hexagons. Within the grasshopper you could use cullPatern to select the items that will be sent to the shapeDiverDisplayGeometry component.

My question is how to create a jsonAcess that receives the variables of each hexagon?

In the documentation it shows that we must use the textimput component, but I cannot define a json with an array for a number of items that are variable within the default text of the textimput component.
MOSAIC - V09.gh (41.1 KB)