Hello everyone! I am a beginner in Grasshopper and my purpose is to arrange the objects on a grid. I organized my objects in groups and I want to place the first object on the first group random on the grid. After the second one has to be placed as far as possible from it, same thing being applied to the next objects of the group. When the objects of the first group are placed, exact the same procedure goes for the other groups too.
I managed somehow to move the objects but not the way I wanted. I would appreciate if somebody could help me with this issue, since it is an important part of my project for university.
I also uploaded the Rhino and Grasshopper files. Thank you very much!
The script is a little long to go through. Based on your description, it seems to go into a loop. So if the first circle is placed as above, the second one will have to go to the corner. and the third the other corner of the entire grid. Then the 4th would go back to overlap with 2, 5 with 3, etc…Did you want farthest from all previously placed objects? So the third should be placed where distance-from-2-to-3 + distance-from-1-to-3 is maximal
First of all, I thank you for replying . Yes, I want each placed as far as possible from the previous object. I know it might be a long algorithm in Grasshopper. Actually, is part of my project: first developing some rules in order to place furniture in the rooms and generate automatically in Grasshopper. This rule with one object as far as possible from previous one is one rule that I implemented. I searched a lot how to do it and I tried another way to move the objects but I am still stuck.
I have what you want (well … “almost”) written long time ago for entirely different purposes. It gets a Points List (BTW: a mesh demo [where the points List in question is the mesh face canters] is provided as well in order to better visualize the results) and searches recursively furthest points according the 4 available options. Recursion means that for each generation it finds points (that comply with the option picked) VS the points sampled in the previous generation. The first item per branch is the randomly picked start point. Roll the bones re executes the code meaning a new collection.
Thank you very much @PeterFotiadis ! It is what I want! I will try to update it to my file and to implement more objects. I was thinking that it could be done also by components from Grasshopper but also this possibility will help me for the uni project!
Well … the thing with code is that makes life exceptionally easy OR incredibly uncomfortable (case no coding experience) so don’t rush to thank me, he he.
More bad news:
There’s no C# to Python auto conversion … thus you’ll need a bilingual friend (knowing well recursion) in order to get that in Python.
GH is a-cyclic by design meaning that for “loops” of that type … blah, blah (but potentially you can use things the likes of Anemone).
After getting the points … well … here comes the real pain: Imagine that you have to place a gazillion of “realistic” things using properly defined planes (classic plane to plane transformations). If the things are not Instance Definitions you’ll end-up with a Rhino file the size of Godzilla. Meaning that the main dish on that task of yours is … well … it’s obvious. .
While in the Instance Definitions placing phase (within some C# loop - obviously) you can (having inquired the Instance and knowing x,y.z box sizes etc etc) “filter” the placement if this or that rule is violated. For instance say that you have placed already a “long” object [a sofa] and comes next a smallish one [a chair] meaning that the “furthest” rules or yours MUST take into account the sizes/topology of the desired objects for placement (criteria related solely with distances between grid points are NOT satisfactory/restrictive enough). This maybe sounds like nuclear science but actually is very simple.
Given the opportunity: if you use Instance Definitions (simple or nested) ALWAYS define them with regard Plane.WorldXY. That way placing them later on makes things rather simple.
Try 3 the hard way: use a “realistic” thingy (like a highly detailed furniture object) and place it (Orient) many many times around. Count the time required (“zero” with Instance Definitions) Then save the Rhino file and count the mega bytes (“rather few” with Instance Definitions).
Notify if you need a C# demo on 3/4 (the critical phases for tasks like yours, especially if we break apart from simple “rooms” and go into big collections describing big/complex layouts etc etc).
My rhino file has around 2.8 Mb. I tried to reduce the number of points (in Archicad) before I imported it to Rhino. I tried in the previous version that I did to move more objects at the same time but I thought I can solve it only by using Grasshopper commands. I will download the Anemone to see if I can do with it.
Here you can choose random one point on the grid, and than the optimization will place the others as far as possible from the initial object. You can do it with Galapagos for exmaple.
I used David Stasiuk’s gene pool editor, so you don’t have to manually edit the gene pool.
I made a boolean which tests, if the objects are intersecting with each other. With Octopus, you can insert a boolean as fitness, so you just get result with no intersection.
You could also use “Delaunay Edges” on all object centers and use the “Curve length” to find the solution where also B,C,D,E have the biggest distance to each other.
If you want to repeat the step, add the placed objects of the first step to the “merge component” before testing for intersection in the second step and so on.
Wow, thank you very much @tim.stark ! It really does help me a lot! I will install the Octopus in order to make the boolean as fitness. A question, I would have… if I add more groups of furniture can I roll them in the same time with this optimization or should I do separetely for each group?
Your welcome.
It’s possible to do it in one optimization, but it’s easier for you, if you do it in more steps. Just add the objects from the steps before to the merge component to test if they intersect.
The only thing to mention is, that Octopus needs a true boolean when you want to open it. If it’s wrong you have two possibilities:
change the gene pool manually so that they don’t intersect
invert the boolean, open ocopus, and delete invert