Introduction
LDraw is an open standard for describing models
built from LEGO-style bricks, begun by James Jessiman’s program of the same name and
now maintained by the LDraw.org community. The same text format holds finished models
(.ldr), the parts and drawing primitives of the shared parts library
(.dat) and models bundled with the files they need
(.mpd).
Structure
Each line is one command and starts with a line type: 0 for comments and meta commands, 1 to place another file with a colour, position and 3 × 3 matrix, and 2 to 5 for lines, triangles, quadrilaterals and optional lines. A model is mostly type 1 lines naming parts; the parts themselves are files in the installed library, built from sub-parts and primitives in the same way.
0 Two bricks
0 Name: two.ldr
1 4 0 0 0 1 0 0 0 1 0 0 0 1 3001.dat
0 STEP
1 1 0 -24 0 0 0 1 0 1 0 -1 0 0 3001.dat
There is no signature. A file is recognised by its first line being a type 0 title and
the following lines starting with the numbers 0 to 5; an MPD file begins with
0 FILE.
In this reference
- Text rules and line types – encoding, units, file search, line types 0 to 5 and the basic meta commands
- File header – title, author, file type, licence, categories, keywords, preview, history and repository headers
- Colours – inherited and direct colours, dithered codes, the
!COLOURdefinition, finishes and materials - Colour table – all 322 official colour definitions of
LDConfig.ldrwith every attribute, and its avatar lines - Part numbers – file names, part numbers, variants, shortcuts, pattern codes and stickers
- Library standards – precision, geometry limits, orientation, stickers, primitives, translation files and licence lines
- MPD and extensions – multi-part documents with embedded data, back-face culling and texture mapping
- Program commands – the unofficial meta commands of LeoCAD, LDView, LDGLite, LSynth, Bricksmith and other programs, and Stud.io’s texture, item number and connection lines
- MLCad commands – rotation steps, ghosting, hiding, groups, buffer exchange, rotation points, generated springs, hoses, belts, arrows and plates, and the sections of
MLCad.ini - LPub3D commands – the building instruction commands of
0 !LPUB: ignoring and substituting parts, inserts, build modifications and layout keywords - LDCad commands – the lines of
0 !LDCAD: groups, markers, flexible paths, springs, part snapping, mirroring and the shadow library
Not described
These pages follow the specifications published by LDraw.org. The explorer has no LDraw viewer, so a dropped file shows as text.
Known, not yet covered
- Viewer: there is no LDraw plugin.
Unknown
- What Stud.io’s
PE_TEX_NEXT_SHEARline changes. - How Studio writes texture coordinates for quadrilaterals.
- The full list of group and element numbers in Studio’s
PE_CONNconnection lines, and the meaning of their cell values.
Also used for
.mpdMPEG-DASH Media Presentation Description – The MPEG-DASH manifest: XML periods, adaptation sets and representations..datWindows registry hive (NTUSER.DAT) – A per-user registry hive when the file is NTUSER.DAT or USRCLASS.DAT; .dat is a generic extension.
Links
Software
Developers
- LeoCAD source – reader and writer (C++)
- three.js LDrawLoader – loader for the web (JavaScript)
- LDView source – viewer (C++)
- LSynth source – hose and band synthesiser (C)
- LPub3D source – building instruction editor (C++)
Reference
- File Format Specification – text rules, line types and basic meta commands
- MPD and image data specification
- !COLOUR language extension
- Back Face Culling extension
- !TEXMAP language extension
- Official Library header specification
- !CATEGORY and !KEYWORDS
- !AVATAR specification
- Official Model Repository specification
- LDConfig.ldr – the official colour definitions
- Official Library Part Number Specification
- Official Parts Library Specifications
- Library Sticker Box Standard
- Primitives Reference
- Localisation Guideline
- MLCad – the author’s site with the format specification of MLCad’s extensions