I’m trying to solve a very specific data structure problem in Grasshopper.
I have a series of curves (one curve per level), and each curve is divided into the same number of points (for example, 3 points per curve using Divide curve).
The points are already organized as a Data Tree: each curve is a branch and all the points on the curve are the indecies.
what i need is a way to select a point on each curve using a slider. but i need to be able to pick different item index from each branch.
later the point selection will create a curve thatll be optimized to be the longest curve, using galapagos.
The important constraint is that I cannot use one slider per curve, since the number of curves may change and the solution must remain parametric.
Not sure I follow the process, or if there are other ‘rules’, such as whether this curve should be ‘inside’ or ‘outside’ of the guide circles/surface, whether the starting point count per curve will stay the same or be allowed to change, whether you’ll use one or multiple randomizing seeds, etc., but for now, just a basic guess:
Please explain more about the end result you would like to see. You want a curve twisted/curled around your vase-like shape?
Galapagos is great, but needs inputs like slider to manipulate. I don’t know about addiding sliders on the fly. So what you need hast to be present at start. (and that could be one or more sliders manipulating the measurements of the curve you need). So I guess you need to work on a “work around”.
help.gh is not a very helpfull name for a *.gh file, You probably can do better then that
use gene pool and POOL CONTROLLER from Heteroptera plugin to have your slider updated everytime
note: it works well if the count in the gene pool remains fixed within the same run of galapagos (It’s not clear if you mean it can also change during the same optimization)
Each curve is divided into the same number of candidate points, and exactly one point must be selected per curve.
The selection must be deterministic and controlled by a single genome input for Galapagos (not one slider per curve).
Randomness was only mentioned earlier as a test, but it is not part of the final approach.
Yes. The end result is a single continuous path connecting one selected point per stacked circle (top to bottom). The path lies on the surface created by lofting the circles, so it can appear twisted/helical around the vase-like shape.
About Galapagos:
Exactly, its needs all inputs present at the start.
That’s the core challenge here: I can’t use one slider per curve, since the number of curves may change.
I’m therefore looking for a workaround where a single genome parameter encodes the per-curve point selections (discrete indices), so Galapagos can still optimize the total path length.
If the interpolated curve cannot be ‘inside’ the lofted surface, and if this curve has to pass through each one of the sections (circles), then you probably want to connect the points with “interpolate on surface”
Can you elaborate on this ‘deterministic’ selection?
What I meant by ‘random’ was whether the selection of each point per curve depended on a specific/expected index (doesn’t sound like this is the case, why would you need galapagos) or if galapagos could ‘determine’ the points (means it ‘finds’ the indices by going through all points.
Sounds like you want to use the ‘gene pool’ to include all ‘ranges of indices’ - but you have to manually set the number of genes corresponding to the number of circles, then galapagos can control this pool.
first thought now: Why not a line twisted around the object? you have a starting point and the endpoint can be rotated x times around the object (with a slider).
and pull curve onto the surface.
if it has to be connected to specific points on all layers, you could use closest object to find the nearest specific point and interpoiate as @René_Corella suggested.
Please brainstorm a bit more with us. Regards, Eef
Thank you all for the feedback! this is very helpful.
I’m attaching my current Grasshopper file to better show where I’m at, since I realize the explanation alone was a bit abstract.
The overall goal is to generate the longest possible path that:
selects exactly one point per curve
goes from the top curve to the bottom curve
lies on the surface created by lofting the circles
is continuous and does not self-intersect
always progresses downward (no upward segments)
The optimization itself is already working reasonably well using Galapagos.
I’m maximizing the curve length while applying penalties for upward slope and self-intersections.
Visually, the results are quite convincing.
At the moment, however, the point selection is controlled by multiple sliders
(one slider per curve/per branch), which is not ideal.
This is the part I want to improve.
The higher level objective is to replace this setup with a more compact and scalable parameterization. Ideally a single genome (or structured genome) that can select one index per branch, while keeping the solution parametric if the number of curves changes.
Based on the suggestions here, I’m currently looking into using Gene Pool/Pool Controller from the Heteroptera plugin as a way to encode per-curve indices in a more elegant way.
If you have suggestions for improving the genome structure, simplifying the current logic, or alternative approaches to selecting one point per curve under these constraints,
This is the only way you can dynamically control the number of sliders.
However, you could also move away from your methodolgy of using multiple sliders and create a subsurface from the revolution body, then construct a curve through the points where the individual rungs intersect the boundary of this region.
I replaced the multiple per-curve sliders with a Gene Pool controlled by a Pool Controller, and it seems to work really well.
The optimization now runs smoothly and updates the Gene Pool values during the process, so this turned out to be the right solution for the problem I was trying to solve.
I’ve attached the updated Grasshopper file.
If you see any further opportunities for improvement or optimization, I’d be happy to hear your suggestions, but overall the methodology seems solid.
I was only focusing on the selection point part and the galapagos problem, while ignoring and not understanding well enuogh the model and not seeing the big picture
You have an untrimmed surface (so it’s like a deformed rectangle with its U and V domain) and your curves are a series of sections in V direction.
If you pick a point for each curve and use Curve on surface component, you are connecting your point moving inside the rectangle, so the solution to get the longest curve is just alternating 0-19 (or 19-0)