Lego bricks in FreeCAD

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
edgarinventor
Posts: 1
Joined: Mon Sep 25, 2017 10:08 am

Re: Lego bricks in FreeCAD

Postby edgarinventor » Mon Sep 25, 2017 10:14 am

Those are great files, I'm new to Freecad, and the steps on that 2*2 brick are teaching me new stuff about Freecad.
I'm about to make a 2*2 - 1 plate brick, to lodge 10 mm neodymium cubes. (Y)
User avatar
fosselius
Posts: 338
Joined: Sat Apr 23, 2016 10:03 am

Re: Lego bricks in FreeCAD

Postby fosselius » Mon Jan 14, 2019 6:24 pm

I revive this thread with:
https://gitlab.com/maidenOne/freecad_lego

I plan to add a workbench for easy placement and part selection.

This will mostly be an excorcise in GUI development on my part.

I also plan on adding a few parts, enough to build a small lego set. Many parts can be autogenerated, but i like to have "proper" freecad parts with sketches instead of a "python object" to allow for easy modification. That said, i will probably improve the lego generator script as well.

Contributions are welcome.

Initially this was just to stress test freecad, especially realthunders link implementation.

Legos base measurement (LU) is 0.4mm, a standard 1x1 is 20 LU wide, that is 20x0.4=8mm wide.
A 2x2 is 2x20x0.4 etc.
headlight.png
headlight.png (20.76 KiB) Viewed 745 times
ldraw_bitsnpieces3.png
ldraw_bitsnpieces3.png (15.24 KiB) Viewed 745 times
original.png
original.png (133.48 KiB) Viewed 745 times
For finding the "proper" piece name/id use:
https://www.bricklink.com/v2/catalog/ca ... age?P=3001
User avatar
fosselius
Posts: 338
Joined: Sat Apr 23, 2016 10:03 am

Re: Lego bricks in FreeCAD

Postby fosselius » Thu Jan 17, 2019 12:13 am

I have made some progress, added a few more parts, and started on the "add part menu", as i have had some issues with the built in thumbnail support (its not always playing nicely..) i have decided to write my own thumbnail generation script and handle the images separated from the design file. This gives me a bit more control over how the thumbnails are generated and makes life easier for GUI development.
Screenshot from 2019-01-17 00-49-06.png
Screenshot from 2019-01-17 00-49-06.png (83.45 KiB) Viewed 648 times
Screenshot from 2019-01-17 00-49-20.png
Screenshot from 2019-01-17 00-49-20.png (28.77 KiB) Viewed 649 times
Here is a scroll-able list view of push buttons, right now they just print the part number when pressed, later when its integrated in FreeCAD they will import the design file in the active document. (or use Links).
Screenshot from 2019-01-17 00-47-29.png
Screenshot from 2019-01-17 00-47-29.png (98.1 KiB) Viewed 649 times
I will also add a move tool that has "snap to grid" move where the grid will be locked to sizes that matches Lego Units for easy placement and rotation.
Placement and rotation might be separated into different tools or different steps.

A cool thought is to start from the Glass WB and add my stuff above it, but have not had time to look at it yet.

The end goal is to make it user friendly enough for my two oldest kids (4 and 5 years old).
User avatar
fosselius
Posts: 338
Joined: Sat Apr 23, 2016 10:03 am

Re: Lego bricks in FreeCAD

Postby fosselius » Thu Jan 17, 2019 1:15 pm

Built my first construction today!
Screenshot from 2019-01-17 14-07-26.png
Screenshot from 2019-01-17 14-07-26.png (717.44 KiB) Viewed 613 times
Screenshot from 2019-01-17 14-02-04.png
Screenshot from 2019-01-17 14-02-04.png (39.71 KiB) Viewed 613 times
I noticed that the default rendering looks to have a miss aligned z buffer, got the same result with 0.17 and 0.18 app images, but the issue disappered after zooming and panning the view a bit then return to the "front view"...
Screenshot from 2019-01-17 14-01-38.png
Screenshot from 2019-01-17 14-01-38.png (9.84 KiB) Viewed 613 times
Attachments
legoHouse.fcstd
(560.78 KiB) Downloaded 17 times
User avatar
Kunda1
Posts: 4755
Joined: Thu Jan 05, 2017 9:03 pm

Re: Lego bricks in FreeCAD

Postby Kunda1 » Thu Jan 17, 2019 2:28 pm

Niiiice!
What a cool dad you are :D
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Zolko
Posts: 257
Joined: Mon Dec 17, 2018 10:02 am

Re: Lego bricks in FreeCAD

Postby Zolko » Mon Jan 21, 2019 11:40 pm

fosselius wrote:
Thu Jan 17, 2019 1:15 pm
Built my first construction today!

just to see if it's posible: used your bricks to make a small assembly :ugeek: The upper LCS are located on the circles of the top bumps, and the lower ones are translated by -9.6mm (hardcoded)

asm_Lego.png
asm_Lego.png (320.56 KiB) Viewed 530 times
Opens only with realthunder's new asm3 AppImage.
Attachments
asm_Lego.zip
(115.18 KiB) Downloaded 11 times
User avatar
fosselius
Posts: 338
Joined: Sat Apr 23, 2016 10:03 am

Re: Lego bricks in FreeCAD

Postby fosselius » Tue Jan 22, 2019 7:15 am

Great, fooling around with assemblies of different kinds is the prime motivator for me.

If you got a bunch of LEGO bricks laying around (real or virtual), its very tempting to put them together ;)

Thats also the reason i went with a slightly simplified version of the blocks, skipped a few distances and indents, i want to stress test number of objects, not number of faces. Its also easier to modify the simplified blocks as there is fewer steps/sketches used to create them.
User avatar
Kunda1
Posts: 4755
Joined: Thu Jan 05, 2017 9:03 pm

Re: Lego bricks in FreeCAD

Postby Kunda1 » Wed Jun 26, 2019 11:09 pm

Image

Can we build something like that ? :dizzy_face:

Source: https://www.reddit.com/r/Sketchup/comme ... um_falcon/
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Zolko
Posts: 257
Joined: Mon Dec 17, 2018 10:02 am

Re: Lego bricks in FreeCAD

Postby Zolko » Tue Jul 16, 2019 7:44 am

Kunda1 wrote:
Wed Jun 26, 2019 11:09 pm
Can we build something like that ?
yes, if we have the corresponding Lego parts, assembling them to that is piece of cake. The difficult bit is to actually model all those Lego bricks. There is a script to make rectangular Lego bricks of many shapes and sizes, but nothing for the more fancy ones.
chrisb
Posts: 16831
Joined: Tue Mar 17, 2015 9:14 am

Re: Lego bricks in FreeCAD

Postby chrisb » Tue Jul 16, 2019 8:47 am

The author says he built it in two weeks ...