# LDraw

LDraw is a system of freeware tools and a 3D graphics file format standard for modeling Lego creations.

## History

The LDraw file format and original program were written by James Jessiman, although the file format has since evolved and extended. He also modeled many of the original parts in the parts library, which is under continuous maintenance and extension by the LDraw community.
Following Jessiman's death in 1997, a variety of programs have been written that use the LDraw parts library, and file format. LDraw models are frequently rendered in POV-Ray or Blender, free 3D ray tracers.

### LDraw.org

In 2003, LDraw.org organization has been established, which main task is set to further develop LDraw file format and extend LDraw parts library. Organization is controlled by members of LDraw.org Steering Committee (LSC for short), elected by users of LDraw.org forum. Core members of LDraw.org are in close ties with James Jessiman's family, which is the owner of the LDraw™ registered trademark.

### James Jessiman Memorial Award

Since 2001, LDraw.org project org's awards notable contributors with the James Jessiman Memorial Award.
Recipient is selected by LDraw.org Steering Committee, and approved after a consultation with Jessiman's family.

### Recipients

* 2001 – Steve Bliss
* 2002 – not awarded
* 2003 – Jacob Sparre Andersen
* 2004 – Lars C. Hassing
* 2005 – Michael Lachmann
* 2006 – Orion Pobursky
* 2007 – Kevin Clague
* 2008 – Philippe Hurbain
* 2009 – Tim Courtney
* 2010 – not awarded
* 2011 – Travis Cobbs
* 2012 – Steffen Lohse
* 2013 – Magnus Forsberg
* 2014 – Sergio Reano
* 2015 – Roland Melkert
* 2016 – Nils Schmidt
* 2017 – Chris Dee
* 2018 – Michael 'Mike' Heidemann
* 2019 – Gerald Lasser
* 2020 – Lasse Deleuran
* 2021 – Leonardo Zide, software engineer at Treyarch, author of LeoCAD (an open-source program for creatiing virtual Lego models with LDraw).
* 2022 – Takeshi Takahashi
* 2023 – Massimo Maso
* 2024 – Evert-Jan Boer

## File format

LDraw file format describes "part" (representation of Lego brick) as a set of geometric primitives ("p") in a form of polygonal triangulated mesh.
LDraw "models" consists of LDraw "parts", same way as Lego models consists of Lego bricks.
LDraw file format is plain text file format, and uses comma-separated syntax definition of values.

### Units

LDU (LDraw Units) — is a base distance unit used in the LDraw format, equals to 1/20 of pin step (distance between centers of 2 closest pins on plate), which in turn almost equals to 0.4 millimetre.
Units comparison table :
| 1 = | LDU | mm | LU | Flat | P | Stud | Brick | in | Comment |
| LDU | | 0.4 | 1⁄4 | 1⁄8 | 1⁄20 | 1⁄20 | 1⁄24 | 1⁄64 | LDraw Unit — base unit |
| mm | 21⁄2 | | 5⁄8 | 5⁄16 | 1⁄8 | 1⁄8 | 7⁄64 | 3⁄64 | millimetre = 0.1 cm = 0.01 dm = 0.001 m |
| LU | 4 | 1.6 | | 1⁄2 | 1⁄5 | 1⁄5 | 1⁄6 | 1⁄16 | Lego Unit = 1 p («plastic») — thickness of brick wall |
| Flat | 8 | 3.2 | 2 | | 2⁄5 | 2⁄5 | 1⁄3 | 1⁄8 | plate height without pin — distance between edges of closest pins |
| P | 20 | 8.0 | 5 | 21⁄2 | | 1 | 5⁄6 | 5⁄16 | pin step— distance between centers of two closest pins |
| Stud | 20 | 8.0 | 5 | 21⁄2 | 1 | | 5⁄6 | 5⁄16 | 1x1 brick width (real width: P-0.2 mm = 7.8 mm) |
| Brick | 24 | 9.6 | 6 | 3 | 11⁄2 | 11⁄2 | | 3⁄8 | brick height without pin |
| in | 64 | 25.4 | 16 | 8 | 31⁄5 | 31⁄5 | 31⁄12 | | inch = 1⁄12 feet = 1⁄36 yard |
| Notes: dimension in and mm are approximated (in mm — rounded to the first decimaldigit) ||||||||||
Some editors (like, LeoCAD) displaying dimensions and coordinates using only LDU. For measuring and converting sizes from LDU to other units and vice versa, LDraw users created few parts in a form of ruler, that could be used directly in LDraw editors during visual modeling, that especially useful for scale model making.

### Scale

LDraw, same as Lego, uses 1:42½ (Lego minifigure scale) as base for scaling real world object for scale modeling. Its may drift between 1:40 to 1:43, which are popular among other interests.

### Specification

The LDraw format can divide a model into steps so that the building instructions can be incorporated into the design, and also allows for steps that rotate the camera and even move parts around in an elementary fashion. It also allows for models to be incorporated in the construction of larger models to make design easier. This also makes the file format space efficient: instead of specifying the polygons of every single stud of a specific brick for example, a shared stud file is included multiple times with transformation applied.
Parts, models, sub-models and polygons are all treated the same and are not specific to Lego models (only the parts library is). The format could be used to store any type of 3D model. Some have created bricks of other building systems for use with LDraw.
The following main three filename extensions are used by LDraw:
* files implementing a part, subpart or primitive use .dat
* a Lego model consisting of 1 or more bricks use .ldr
* multiple .ldr files can be aggregated into files of type .mpd
The file format uses plain text data, and uses the charset UTF-8 without BOM.

### Example File: 3003.dat, the Implementation of a 2 x 2 Brick

The above code defines the basic 2×2 brick. It consists of a five-sided box (box5.dat, outside) and an inverted five-sided box (inside), the connection between those two, consisting of four quads (the four lines starting with 4), the four studs on top of it (stud.dat) and the long hollow stud in the inside (stud4.dat).
All lines in an LDraw file are either empty or start with a command number, where 0 means no command (though over time, some lines starting with 0 followed by specific text in capitals also got a meaning as meta commands). The command 1 for example includes a subfile. It specifies the file's path and a transformation matrix that should be applied to it, as well as its color (where 16 means "use the color that was used when including the current file"). Command 4 specifies a four-sided polygon. There are also commands that define 2D lines. Such lines give the parts a clear contour even in non-shaded orthographic renderings.

### Example File: pyramid.ldr, a Lego Model of a Pyramid

The following code specifies a simple pyramid model with three layers made of 2 x 4 bricks (brick # 3001) with changing color and a 2 x 2 brick on top.

## Other examples

* A racecar created with LDraw
* A small town built using the LDraw system of tools and rendered in POV-Ray. The model contains about 250,000 parts.
* A flying mechanism that was built in Lego Masters Denmark rebuilt in LeoCAD
* 4K rendering of the flying mechanism generated via POV-Ray render option inside LeoCAD
* A spaceship built in LDCad
* Car viewed using Bricksmith