Hi everyone,
I would like to randomly distribute multiple objects inside specified areas without having any intersecting objects. (randomly scale and rotate these objects is optional)
The final result should be like a stone paved road.
I am relatively new to grasshopper. reading and testing files from similar posts didn’t helped me much.
In the attached gh file you can see my progress so far.
If you could help me solve this issue or point me to the right direction, I would be grateful.
You didn’t search enough but sometimes using the search engine on discourse is not the best. I like to use google with key word like “site:https://discourse.mcneel.com/ keywors …”
The packing density of @laurent_delrieu’s solution is very impressive! Must be a different algorithm than just filtering overlapping curves? Curious how it works but not curious enough to install his plugin. Is it fast?
Reminded me of an old thread here:
I started yesterday to adapt it to your code but it’s slow and @laurent_delrieu’s results are better. Still, it’s interesting enough that I resumed tinkering this morning. It got complicated.
The green group is an Anemone loop to filter out overlapping shapes. I used a low ‘Count’ value (5) to speed up the debug process and focused first on only the small square on the right, using the small yellow group to work with only one branch at a time. The gray group handles the special case where one shape completely engulfs another without intersecting.
I tried a variety of methods for maximum speed, including RUnion(Region Union). It returns one result when two shapes intersect or one “engulfs” the other, or one result when they don’t. Effective but slow.
Later I added a second loop (large light yellow group) to traverse all branches, passing one at a time to the first loop in the green group. And a Value List(white group) to switch between “All branches” and “One branch”. Using a ‘Count’ value of 30, the profiler shows ~16 seconds for the small square and 1.7 minutes for the large rectangle.
Using a ‘Count’ value of 130, the profiler shows close to six minutes for the large rectangle!
Hello Joseph,
the principle is simple. Everything is transformed to mesh then to bolean Pixels. A big matrix for the sheet. And more little matrices for the shapes.
So for less than 1 million pixels and 1 million of tests it takes ~10 seconds.
here the outputs with pixels not touched.
Hello, I’ve enjoyed reading this thread and plugging in my own files into the script. I was hoping I could get some guidance on a way to populate the region with a designated percentage of each shape, eg. 30% largest, 10% medium etc… would it be best to tweak the script in this thread or to make a new one to achieve visually similar results?