Create multiple geometries from same input fields

I try achieve creating multiple geometries from single input fields. Let say I want to create simple boxes with different dimensions in different positions. Currently I could achieve this by multiplying the number of sliders for the position (in this case “move”) so to create a list and feed it into the box component. However, I would like to create those boxes from only two sliders, one for the dimension and one for the position, and another additional like the ID of the object to choose which one I am modifying. If I want to create 10, then I could choose an index from a list and use the two sliders, but not 2x10.

To further sophisticate my goal, sometimes I want to create spheres instead of boxes. So let say I have 10 objects, but 3 of them are spaheres, and 7 are boxes. Then preferably I would have only 2x2 sliders. So 2 for spheres (1 radius, 1 for position) and another 2 for boxes (1 dimension, 1 position).

My use case will be more complex but this is my minimal working example for my problem. My question is how to achieve this with (preferably) native GH components? Please see my GH file attached and a screenshot for the problem.

repeating-objects.gh (9.5 KB)

you can use the Random component to generate random numbers in a defined range

each Random component is driven by a Seed slider: imagine an infinite book with infinite numbers written on each page, the Seed identifies the page number in such a way you are always able to go back to page # and re-instate that particular random configuration


RandomBoxesSpheres.gh (20.4 KB)

Hi @inno thanks for your answer. …I need a bit more control on the number of objects I have and even their positions. So lets say I have a specific x,y and z coordinates for each objects (one of their corners for instance) …then I want to change their dimensions by selecting them in some way (i.e with an item index). …I feel that I would need a “recorder” components but still not sure how to achieve this. …the Seed idea looks promising anyhow, but I need to be able to place my geometries into certain locations.

ok, so you would like something like a “remote controller” that allows you to go through a list of geometries, and be able to chose if and how modify only the currently selected one by using a couple of sliders, or add a brand new geometry through the very same controls

not sure how this could be achieved with vanilla components… I imagine it like a csv with all the numerical data of your geometries, but instead of changing the values manually you would like to select/add a new row using sliders, and be able to modify each column of that row just by using sliders

Not long after I started working with GH, I wished for this very same capability. A simple example would be defining a series of section curves used by Sweep or Loft to create a boat hull. A single set of sliders would be reused for multiple sections with a selector to choose which one they apply to. Set values for each section would be retained when another section is selected.

Among other issues, two obstacles stood out:

  1. Sliders or knobs must be updated with appropriate values as each section is selected.
  2. Inputs must be restricted to single values in this case whereas “proper GH” usually allows for lists.

@inno yess, exactly, you have got my point :wink: …I am also ok to write a Python code to manage this stuff if there is no really a native solution for this kind of problem.

Thanks @Joseph_Oster how long you have gone with your challenge? Do you think what I’m explaining is possible with GH? …if I understand well, we cannot really update a slider value or other sort of input fields in GH. I mean programatically.

it might be feasible through scripting, but there must be a very clear separation of when each slider is an input, and when each slider “resets” its own position into something else and becomes an output

I’m not able to do it, but I can imagine how it might be structured (in a very fuzzy way…)

it would be the very same of having “motorized faders” in music mixers + a rotating knob

the rotating knob is linked to a list of data, each time you move the knob you read a different branch

each time a new branch is red through the rotating knob, the data in that branch is sent to the motorized faders (sliders), so they change their current-value to match the ones they are provided with (during this, the data selected through the knob is an input for setting the sliders values)

as soon as each slider matches the current data in that branch, then the slider-current-value controls the data-value it is connected to (sliders are the input for the data-branch set by the knob)

Thanks @inno I’ll try to implement this as it sounds a good plan, a “pseudo code” :wink: …I’ll share my solution here as soon as it’s found :wink:

Hi @inno just an update on my solution. I wasn’t able to find solution within GH. This is due to the fact that with my limited number of sliders I’ll be not able to produce the same (or required) result. I tried with the data recorder which worked ok in case I know the number of objects. But also that needs to be dynamic, so that cannot really work for me.

I played for sometime with FSM (Finite State Machine) in Python, but I didn’t really get the grasp of it and I am also not so sure if that would eventually work as we always re-run the Python component whatever inputs are changing.

Then, I found my solution outside (the box :wink: ) GH. Since in ReactJS (Javascript) we have fantastic tools for state management, so this is a breeze to dynamically update, create objects. So with that in mind, I can create my user interfaces on the web, and generate a JSON object based on user inputs. I can feed that JSON object to GH and work further with the geometries. In this way I am flexible to create any number of objects, with any desired geometry.

2 Likes