Lego bricks in FreeCAD

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
edgarinventor
Posts: 1
Joined: Mon Sep 25, 2017 10:08 am

Re: Lego bricks in FreeCAD

Post by edgarinventor »

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: 381
Joined: Sat Apr 23, 2016 10:03 am
Contact:

Re: Lego bricks in FreeCAD

Post by fosselius »

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 3584 times
ldraw_bitsnpieces3.png
ldraw_bitsnpieces3.png (15.24 KiB) Viewed 3584 times
original.png
original.png (133.48 KiB) Viewed 3584 times
For finding the "proper" piece name/id use:
https://www.bricklink.com/v2/catalog/ca ... age?P=3001
User avatar
fosselius
Posts: 381
Joined: Sat Apr 23, 2016 10:03 am
Contact:

Re: Lego bricks in FreeCAD

Post by fosselius »

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 3487 times
Screenshot from 2019-01-17 00-49-20.png
Screenshot from 2019-01-17 00-49-20.png (28.77 KiB) Viewed 3488 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 3488 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: 381
Joined: Sat Apr 23, 2016 10:03 am
Contact:

Re: Lego bricks in FreeCAD

Post by fosselius »

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 3452 times
Screenshot from 2019-01-17 14-02-04.png
Screenshot from 2019-01-17 14-02-04.png (39.71 KiB) Viewed 3452 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 3452 times
Attachments
legoHouse.fcstd
(560.78 KiB) Downloaded 102 times
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Lego bricks in FreeCAD

Post by Kunda1 »

Niiiice!
What a cool dad you are :D
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Lego bricks in FreeCAD

Post by Zolko »

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 3370 times
Opens only with realthunder's new asm3 AppImage.
Attachments
asm_Lego.zip
(115.18 KiB) Downloaded 89 times
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
fosselius
Posts: 381
Joined: Sat Apr 23, 2016 10:03 am
Contact:

Re: Lego bricks in FreeCAD

Post by fosselius »

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
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Lego bricks in FreeCAD

Post by Kunda1 »

Image

Can we build something like that ? :dizzy_face:

Source: https://www.reddit.com/r/Sketchup/comme ... um_falcon/
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Lego bricks in FreeCAD

Post by Zolko »

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.
try the Assembly4 workbench for FreCAD — tutorials here and here
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: Lego bricks in FreeCAD

Post by chrisb »

The author says he built it in two weeks ...
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply