I'd like to build a database (for a machine learning project) of which parts are connected to which part for a large library of (official) Lego sets. Is any such database available or would it be possible to create one from publicly available Ldraw files?

You could imagine that each set is a graph, each node represents a part and the edges of the graph represent that two parts are connected.

  • 1
    This is an interesting question but from my understanding of most LEGO CAD software, bricks are stored as positions rather than as connections. The software knows how each part is arranged but not how they connect. Some parts may be directly adjacent for example but not necessary physically connected. Most connections are made using studs, pins and axles, so it might be possible to analyse positions of those pieces.
    – Ambo100
    Mar 5, 2022 at 15:23

1 Answer 1


Is any such database available

I do not believe that a graph database like this exists.

Would it be possible to create one from publicly available Ldraw files?

This would be difficult to create. LDraw files do not store connection information. They store part locations in 3D space. Modelling tools frequently support snapping parts together and/or snapping to a grid, but that information is not directly stored in the LDraw model files as far as I know.

Going from an LDraw file to a connection graph seems possible, but it would require modelling precise connection information for each part for each connection family. It would then require a physics engine that could model the parts and perform collision detection for each connection point to determine if a connection exists and what it is connected to.

  • Stud.io uses it's own proprietary file format, but it is based on LDraw files and seems to have quite good collision detection... Mar 8, 2022 at 8:39
  • Or, you could feed all the relative coordinates to a machine learning algorithm and make this your machine learning project! Apr 4, 2022 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.