Want to Add Like Lego-like Functionality

I have had many occasions over the years of wanting a parts toolbox in Rhino. More than that I’d like the parts to automatically join at their appropriate interface points, like whole object snaps or magnetic joints. I’ve finally plucked up the courage to play with Grasshopper and realize that it’s probably possible to build my own. I’ve hunted through heaps of cool plugins but not found anything that solves my needs out of the box. So I’m wondering how others would go about this? Specifically I think this probably needs a way to clone parts and a way to magnetically orient and snap whole objects. Pointers in helpful directions to research would be much appreciated.

Like this?

There’s an example file of something similar here:


Here’s an attempt at something a little more Lego like, with a button to add a new brick.
lego.gh (17.4 KB)

I also realised that some changes I made in a recent release have made the rigid bodies slower than before - I’m going to see if I can fix this for the next release.

YES!. That looks ideal. I wasn’t thinking about it as physics so didn’t look at Kangaroo.

Lets see if I can make it work (Rhino Pro / Grasshopper Noob!).

Thank you!

OK, yup, I am a noob. I got polygonassemble.gh working and that gives me great hope. But I have an error with lego.gh. The Solver throws *“1. Solution exception:Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.” * Quite possibly I need to do something other than just click the Add button and expect something cool to happen?

After a reboot lego.gh worked just fine. No idea why it wouldn’t before. Anyway, thank you! That’s an awesome start. Can you suggest how I can:

Limit block orientation
Limit what faces can snap (like top and bottom, not side to side).
Also, after a few blocks are snapped together the cluster tends to start spinning wildly. How can I prevent that?