Nesting or Packing in Grasshopper in 3D space with mesh objects

I am attempting to create a script that is able to optimize and nest geometry within 3D space. An example below:

The geometry used in the simulation will be 3d-scanned watertight meshes.

Actual questions:

  1. Could you please point me in the right direction with regards to what library I should use.
  2. Is there an appropriate method to do this in Kangaroo with Galapagos perhaps, but I am not sure about collision detection in Kangaroo with complex meshes and the ability for Galapagos to provide enough shaking to really determine an acceptable nesting.

I have been reading about the Monte Carlo method as one of the ways of accomplishing the simulation, and this seems to be the method that Autodesk Netfabb utilizes, and it seems close instinctively to the Kangaroo+Galapagos method.

PS the excerpt from the paper with regards to the simulation by Sai S. Tulluri from NJIT:
Analysis of random packing of uniform spheres using the Monte Carlo simulation method (core.ac.uk)

William M. Visscher and M. Bolster [1] approached the problem of random packing by means of Monte Carlo computer simulation of the physical process of dropping spheres into a bin. The spheres position themselves under the influence of a unidirectional (vertical) gravitational force, rather than toward a center of attraction. The computer in three-dimensional were set up as follows: Periodic horizontal boundaries were assumed i.e. the ball (x, y, z) reappears at (x±L„, y±L, z). Balls were dropped sequentially from a random point above the L„ x Lye bin. When a ball was dropped it hits ball ‘m’ or the floor. When it comes in contact with ball rn’, then it rolls down in a vertical plane on ‘m’ until it is in contact with ‘m’ and ‘n’ . Then it rolls downward in contact with ‘m’ and ‘n’ until it makes contact with ‘13’. If the contact ‘m’, ‘n’ and `p’ is stable, it stops. If not it rolls on the double contact that goes down most steeply and so on.

Anytime a ball contacts the floor it stops. The density of random stacks of mono-size and fuzzy mono-size discs was reported as 0.82. According to the author physical shaking increases the density by allowing the structure to seek a configuration of lower potential energy. Code for generating three-dimensional system was built and tested by generating h.c.p system. For this, the bottom layer was carefully placed in a hexagonal array. The subsequent balls were dropped from positions directly above these base balls, but displaced by a certain constant arbitrary amount to fix the direction of initial roll. This procedure generated h.c.p array, only when the base balls were chosen to have radii slightly larger than the radii of the subsequent balls. Keeping the same base ball field and dropping procedure, the distribution of subsequent balls was changed from mono-size to fuzzy mono-size with 10-6 spread. This distorted the regular h.c.p structure after 7 or 8 layers of balls, with sudden transition to a random structure with a density of 0.582.

Did you see this topic?

Thank you Martin,

That looks like it fits the bill. I did try it but it was not what I am looking for (unfortunately). It is prohibitive computationally and works super slow. I am going to have to change course and pursue a 3D tetris type model.

Here is the script for the video below though. I had to modify Daniel Picker’s definition as I couldn’t understand the one in that thread.
3d_nesting.gh (31.3 KB)

Please internalise the relevant inputs by right clicking the component and then ‘Internalise data’.

image

I put some spheres inside your box and the rest of the definition works fine, more or less…

3d_nesting.gh (23.8 KB)

Is there a way including a constrain in it, so that (although my objects are complex 3d shapes) it is optimized only in xy direction? Aldo I see this post is one year old. Is there any development in this field?

Did you see this topic:

This is not what I want. The image shows it is optimized without any constraints.

Martin Siegrist via McNeel Forum <notifications@mcneel.discoursemail.com> ezt írta (időpont: 2025. jan. 2., Csü 7:15):

Are you aware of the Rigid Body Support goal?

Alas it is completely new for me.

Do you have any experience in Grasshopper?

Can you share some of your objects?

yes I have a couple of years experience in Grasshopper, however I am not a programmer just an architect.