Files accepted into the official LDraw parts library obey the file format and the further rules below. A model file is not bound by them, and some older library files do not conform; a reader should accept both. File names are covered under part numbers, header lines under file header. An old part is not edited only to make it conform, but when it is resubmitted to the Parts Tracker for another reason, its non-conforming lines must be brought up to date.
Numbers
- Three decimal places are the normal precision for parts, subparts and primitives that are not meant to be scaled; four for high-resolution primitives and primitives designed to be scaled. Never more than five.
- Trailing zeros and superfluous leading zeros are removed (
1.5,1). The zero before a decimal point is optional:0.5and.5are both valid.
Geometry
- The matrix of a type 1 line must not be singular or contain a row or column of zeros.
- Each interior angle of a triangle or quadrilateral lies between 0.025° and 179.9°. A concave quadrilateral is split into two triangles.
- A quadrilateral is flat if, split either way into two triangles, their normals are at most 3° apart; under 1° is required unless the author justifies more.
- No type 2 line may overlap another type 2 line, even in part.
- Type 5 lines may not overlap each other, except the complementary pair at a seam of curved surfaces, whose control points are tangent to the curve.
- Part, but not all, of a type 5 line may overlap all, but not part, of a type 2 line. On points A, B, C, D in a row, a line BC with a conditional line AD is allowed; with a line AC, a conditional CD may not be written as AD or BD; along a line AD no conditional line is valid.
- Lines may cross. Overlapping and intersecting polygons are kept to a minimum; small overlaps involving primitives are accepted.
- Two identical geometry lines (types 1 to 5) are not permitted. For types 2 to 5 the order of the vertices is ignored in the comparison, and for type 5 the control points too.
Orientation and origin
- Parts with studs stand studs up (−y) and tubes down (+y).
- Their origin is centred on the topmost group of studs, with the bottom of those studs on the plane y = 0. For hinge-like parts the origin is the pivot.
- Studs are turned so that the logo reads as on the real part. A subpart containing studs should not be mirrored.
Colours and meta commands
- Triangles and quadrilaterals must not use colour 24; type 2 and type 5 lines must use 24.
- Every colour number must be defined in
LDConfig.ldr, except direct colours for the geometry of patterns and stickers. Metallic prints use a metallic colour rather than chrome or pearl. LDConfig.ldritself holds only colours that LEGO has at some time used as the unpainted colour of a material in its toys (the metal of 9 V track counts, paint and sticker ink do not), plus the special codes 16 and 24.- After the header, the only meta commands of an official part are comments
(
0 //),BFCandTEXMAP. Commands of a generating program may remain if they are commented out, preferably with a comment marking the end of the generated section. - Every official part is
0 BFC CERTIFY CCW. - A textured part carries enough ordinary geometry for programs without
TEXMAPsupport.
Shortcuts and flexible parts
- Shortcuts are normally unpatterned. The separate pieces of an assembly that cannot
be taken apart get descriptions beginning with
~. A rigid assembly is given as~pieces and one shortcut; a moving one has a shortcut for each mechanical unit and one for the whole, with-fNfiles for positions. A moving unit that is a single part is not marked with~. Several shortcuts may be needed to cover different colour combinations. Shortcuts of patterned assemblies are considered case by case. - Parts of non-rigid material that are meant to deform (hoses, ropes, strings, springs, fabrics, rubber bands, plastic sheets) are built as series of pieces and offered through shortcuts, with descriptions following the shortcut rules. The flat or at-rest form is the primary one; formed versions are suffixed.
Patterned parts
- Multi-colour mouldings count as patterns. Every patterned part is based on a plain part, which is created even if it was never produced.
- The description is the base description, then
with, the pattern and the wordPattern. For a part with mould variants, the words naming the mould are needed only if the same pattern is printed on more than one variant. - At least one
0 !KEYWORDS Set numberis required; a catalogue reference may follow, as in0 !KEYWORDS Set 10442, Bricklink 973pb0042.
Stickers
- The description starts with
Stickerand the size in studs (z × x) or the shape, and does not end inPattern. Stickers and sticker shortcuts need at least oneSetkeyword. - A flat sticker is a box 0.25 LDraw units thick in colour 16 with no type 2 lines, its top face at y = −0.25 parallel to the x–z plane, the top of the picture toward +z and landscape (x longer than z) when in doubt. The picture is in fixed colours, back and sides in 16.
- A transparent sticker uses 16 for its clear material; the picture's type 1, 3 and 4
lines in such areas are preceded by
0 BFC NOCLIPand followed by0 BFC CLIPif other geometry follows. - A formed sticker has type 5 lines in colour 24 round its curved edges; type 2 lines
are allowed for creases. Its origin may follow the part's, or be explained in
!HELP. - A sticker shortcut contains one part, which may be a composite, and stickers placed as in the official instructions.
Sticker backing files
The backing box is the sides and underside. A sticker covering a whole face of one
part is modelled 2 units inside the face's edge, also when the measured size differs by
1 unit. Sharp-cornered backs use a scaled box5-12, round and oval ones
4-4cylc3, irregular ones triangles and quadrilaterals with conditional
lines. Standard rounded corners have radius 1.5; a back file is required for
rectangles with such corners, and optional but encouraged for another shape and size
that is often reused. Back files are subparts in parts/s, landscape, named
stickerbackZZZxXXX.dat, each number being the width
in LDraw units divided by 20, to one decimal, written as three digits: 143 units gives
072. The name without a suffix is reserved for the rectangle with standard
rounded corners; other shapes of the same size add a letter a to
z. A formed back, made as reuse calls for it and oriented like a formed
sticker, is partbNN.dat, where part is the
part it is formed to and NN runs from 01.
Primitives
Files in p are shared shapes that a renderer may replace with its own
smooth versions. High-resolution versions are in p\48. The
Primitives Reference lists every
file; the names follow a code.
Straight-edged primitives
triangle.dat is a right isosceles triangle in the x–z plane with its edges,
the right angle at the origin and sides of 1. rect.dat is a rectangle of
2 × 2 centred on the origin; rect1, rect2a,
rect2p and rect3 keep only some edges, and
recte3 and recte4 are edges without a face.
box.dat is a cuboid of 2 × 2 × 2 centred on the origin; boxes with faces
missing, such as box5, have height 1 and their origin in the middle of the
missing top face. Triangular prisms are tri3… and tri4. All
may be scaled along x, y and z, but a rectangle is not to be rotated by anything but
right angles. A flat primitive still needs a non-zero y scale.
Circular primitives
They lie about the origin in the x–z plane with radius 1. A prefix
n-f is the fraction of a turn:
4-4disc.dat is a full disc, 1-4edge.dat a quarter circle. A
partial arc starts on the +x axis and runs anticlockwise seen from above (−y). Scaling
x and z equally sets the radius, unequally makes an ellipse; a flat primitive still
needs a non-zero y scale. Regular primitives have 16 segments to a full turn,
high-resolution ones 48. It is better to use or make the right fraction than to rotate
one by anything other than 90° or 180°.
| Name part | Shape |
|---|---|
edge | Circular arc drawn as lines |
disc | Disc sector |
chrd, chrde | Disc segment; with edges |
ndis | Inverse of a disc sector (the square corner outside it) |
tang, tndis | Tangential ring segment; truncated disc negative |
aring | Adaptor ring segment |
ringr | Ring sector of width 1 and inner radius r: 4-4ring4 runs from radius 4 to 5. Longer forms of the name are ringr, ffring and ffringr; the older ri and rin spellings are obsolete |
ering, 1-16chrd, 1-48chrd | Substitution adapters: they refer to nothing visible, and a renderer that substitutes smooth curves fills the gap between curve and neighbouring geometry |
cyli, cyli2 | Cylinder wall with conditional lines; without them (special cases only) |
cylo, cylc | Cylinder wall with edges at both ends; with the upper end closed (numbered forms such as cylc3 exist) |
cyls, cylse | Cylinder cut by an angled plane, 45° by default; with the angled edge |
cylj…, tric | Junctions and intersections of cylinders |
cylrsphs | Cylinder cut by a sphere |
edgh, cylh | Helical edge and helical cylinder |
conr | Cone 1 high toward +y, inner radius r, outer radius r + 1 |
sphe, 1-8sphc | Section of a sphere of radius 1; a spherical corner (one eighth of a sphere of radius 1.414, cut by a cube) |
Tori
A torus section is named tffsrrrr, or
rffsrrrr for a reverse-ratio torus, whose tube radius is larger
than the ring radius. The ring (major) radius is 1, so the file is scaled in x and z.
ff is the sweep as the bottom of a fraction (01 a full turn,
02, 04, 08, 16, 32,
48). s is the part of the tube: i inner,
o outer, q the whole tube (two inner and two outer sections);
a reverse-ratio torus has no inner section. rrrr is the tube (minor) radius,
with four decimals in a regular torus (1333 is 0.1333; unit
means 1). In a reverse-ratio torus four digits have the point after the first
(4600 is 4.6) and five digits after the second (11000 is
11.0). The reference also lists a set beginning tm under the heading
mixed mode. These mix the two resolutions: the ring is divided in 48ths and the cross
section of the tube in 16ths. The prefix was proposed on the LDraw forums in 2017,
for files kept in p/48/.
Boxes, stud groups and text
Boxes are boxF, F being the number of faces, with a
suffix giving the number of edges removed. Either number may take a letter, and the
hyphen is dropped when the face number has one: for faces, o opposite,
t all touching, u the missing faces form a U; for edges,
p groups of edges are parallel, a some missing faces have no
adjacent edges. Rectangles and boxes may be scaled in all three directions. Stud
groups are stugN-XxZ and are not scaled.
Stud primitives are not scaled in x or z, and ideally not in y, so that a renderer can
substitute them; each stud… file has a simpler stu2… twin for
fast drawing, which a part file must never name, and studline.dat reduces a
stud to one line. Lettering primitives, which may be resized, are named
typeffci: two letters for the typeface, the glyph class
(u capital, l small letter, n digit,
s symbol, a accented letter) and the glyph, as in
typestci; some typefaces spell out their name instead
(type-swiss721bt-bold-…).
Technic and other special primitives
Technic axle and axle-hole primitives are not scaled, except along y where the
reference says so. Castellated bush and connector peg primitives are not scaled; peg
hole primitives are not scaled in x or z, though the peghole and
npeghol families may be in y. Gear and rack teeth are not scaled, and the
miscellaneous primitives, each made to fit a particular mating shape, are not meant to
be resized.
Translation files
Names can be translated without editing part files. The guideline puts UTF-8 files
with CR LF line ends in
<LDraw>\localisations\language[-COUNTRY]: an
ISO 639-1 code in lower case and an optional ISO 3166-1 code in upper case. The country
is dropped for a language's most common form, except English, which always has one
(the library's own language is Australian English). The files are
parts.txt, colours.txt, categories.txt and
keywords.txt, the last translated keyword by keyword.
0 LDraw.org Configuration File
0 Name: colours.txt
0 Author: LDraw.org
0 !LDRAW_ORG Configuration UPDATE 2009-09-05
0 !TRANSLATION COLOURS de-DE
0 !LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt
0 !TRANSLATION content locale names what is
translated (COLOURS, PARTS, CATEGORIES,
KEYWORDS or another), which is the file name in capitals. Lines not
starting with 0 are entries "neutral" = "translated", with any spaces or
tabs between the quoted strings. Inside a string, " and \ are
written with a preceding \; a lone backslash is discarded. An optional
entry "~Moved to %s" = "… %s …" translates all moved-file titles. Lines
have no length limit, and a leading ~ or _ flag must be
carried into the translation.
A missing country form falls back to the plain language (de-AT to
de) and then to the library's own English; a readable copy of that neutral
language goes in en-AU. 0 Name: in these files need not end in
.dat or .ldr, the author need not be LDraw.org if the file is
not official, and further comment lines such as 0 !HISTORY may follow.
Applications should use a translation only to show text, never to decide anything, and
keyword translations should avoid repeating the part description.
Licence lines
Library files are licensed under Creative Commons Attribution, and say which version in the header:
| Line | Meaning |
|---|---|
0 !LICENSE Licensed under CC BY 4.0 : see CAreadme.txt | Submitted or edited from 2023-03-05, or all authors agreed to the newer agreement |
0 !LICENSE Licensed under CC BY 2.0 and CC BY 4.0 : see CAreadme.txt | Older file with only some authors agreed; changes in !HISTORY lines before 2023-03-05 are CC BY 2.0, later ones CC BY 4.0 |
0 !LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt | Deprecated wording, meaning CC BY 2.0 |
Attribution names the creator, gives a URL for the work, names the licence with its URL and says whether the work was changed; commercial use is allowed. LDraw.org does not treat as derivative works rendered images, or model files that only refer to parts official when the file was made (parts then unofficial may be included in full, unless shipping large numbers of them is the file's main purpose), or other part libraries it holds no copyright in. Parts converted from the LDraw library are derivative works.