Answers.Body: <blockquote>
  <p>Is any such database available</p>
  </blockquote>
  <p>I do not believe that a graph database like this exists.</p>
  <blockquote>
  <p>Would it be possible to create one from publicly available Ldraw files?</p>
  </blockquote>
  <p>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.</p>
  <p>Going from an LDraw file to a connection graph seems possible, but it would require modelling precise connection information for each part for each <a href="https://bricks.stackexchange.com/questions/1800/what-are-all-the-different-ways-that-lego-pieces-join-together">connection family</a>. 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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-08T08:39:21.113Z
Answers.Text: Stud.io uses it's own proprietary file format, but it is based on LDraw files and seems to have quite good collision detection...
Answers.UserDisplayName: Michael Verschaeve
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-05T15:54:38.307Z
Answers.LastActivityDate: 2022-03-05T15:54:38.307Z
Answers.UserDisplayName: jncraton
Body: <p>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?</p>
  <p>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.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-03-05T15:23:48.117Z
Comments.Text: 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.
Comments.UserDisplayName: Ambo100
Tags: <part-database><connections>
Title: Is there a way to create a database of bricks that are connected in different sets
UserDisplayName: cwitte
ThreadText: # Is there a way to create a database of bricks that are connected in different sets
  
  (Asked by: username_0 on 2022-03-05)
  
  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.
  
  **Tags:** part-database, connections
  > **Comments:**
  > **username_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.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2022-03-05. Score: 4 | Accepted answer
  
  > 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](https://bricks.stackexchange.com/questions/1800/what-are-all-the-different-ways-that-lego-pieces-join-together). 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.
  
  > **Comments:**
  > **username_3**: Stud.io uses it's own proprietary file format, but it is based on LDraw files and seems to have quite good collision detection...  
  
  ---
  
  