LDraw Primitives Reference

This page is a source of reference for the LDraw primitives in the \LDraw\p directory. Primitives are defined as highly re-usable components of LEGO parts modelled for LDraw.

They serve several purposes :
  • To speed up parts authoring by providing a library of components which can be incorporated into several parts
  • To allow rendering software to make substitutions of curved components
Within this reference material the available primitives are categorised into :

Each section contains an overview of the characteristics common to all primitives within that category. Primitives are grouped into classes within each category - one class of primitive serving a similar purpose at different sizes or resolutions. For each class of primitive, a brief description of the purpose of the primitive is provided, with notes on its co-ordinate origin, default size and rules for scaling. A list of the available primitives is shown.


An understanding of the orientation of the co-ordinate axes is essential for authoring a part for LDraw. For reference within this page the axes and their direction is shown in this diagram.

Rectilinear primitives

These rectilinear elements may be scaled in the {x}, {y} and {z} dimensions to make elements of any size. For example

1 16  0 0 0  40 0 0  0 1 0  0 0 20  rect.dat

would generate a 80LDu x 40LDu rectangle in the {x,z} plane.

Although the default orientation of the rect.dat primitive is in the {x,z} plane the LDraw language allows for this to be transformed

1 16  0 0 0  0 1 0  40 0 0  0 0 20  rect.dat

would generate a 80LDu x 40LDu rectangle in the {y,z} plane.

1 16  0 0 0  40 0 0  0 0 20  0 1 0  rect.dat

would generate a 80LDu x 40LDu rectangle in the {x,y} plane.


Two dimensional

Top

Three dimensional

Rectilinear primitives   Top


Curved primitives

LDraw represents curved surfaces as polygons. For circular components two series of primitives are provided.

All the circular primitives are orientated in the {x,z} plane with their origin at the centre of the circle and a default radius of 1 LDu. Primitives are provided for complete circles and for commonly used fractions of a complete circle. Where the naming convention includes a prefix of the form n-f this indicates the fraction (n/f) of the circle drawn by the primitive. Where this fraction is less than an entire circle, the primitive starts at {+x,0} and progresses in a conterclockwise direction when viewed from above {-y}.

To avoid rounding errors, it is preferable to use existing fractional circular primitives, or create a new primitive, rather than rotate an existing primitive by anything other than 90 or 180 degrees. For example, use 3-16XXXX.dat rather than combining 1-8XXXX.dat with 1-16XXXX.dat rotated by 22.5 degreees.




      

1-8disc

      

1-4disc

      

2-4disc

      

3-4disc

      

4-4disc


To avoid matrix arithmetic problems in some renderers, the third dimension ({y} in the default orientation) of two-dimensional primitives must be given a non-zero scaling factor.
LDraw circles are normally formed of 16-sided polygons (hexdecagons) - the regular resolution. For larger elements, where scaling-up of hexadecagons would give too angular an appearance, a series of high resolution primitives based on a 48-sided polygon are available. These may also be used for parts not well suited to a 16-fold symmetry.

These circular elements may be scaled by the same factor in both the {x} and {z} dimensions to make circular elements of greater or less than 1LDu radius. For example

1 16  0 0 0  3 0 0  0 1 0  0 0 3  4-4edge.dat

would generate a circle in the {x,z} plane with a radius of 3LDu.

They may also be scaled asymmetrically in the x and z dimension to make ellipses.

Although the default orientation is in the {x,z} plane the LDraw language allows for these to be transformed

1 16  0 0 0  0 1 0  3 0 0  0 0 3  4-4edge.dat   would generate a circle in the {y,z} plane

1 16  0 0 0  3 0 0  0 0 3  0 1 0  4-4edge.dat   would generate a circle in the {x,y} plane


Two dimensional

Curved primitives   Top

Three dimensional

Curved primitives   Top

Technic primitives

Technic axle primitives

Top

These primitives represent various components of the technic axle and its matching hole. They are orientated in the {x,z} plane. Except where noted below, and in the {y} dimension only, these primitives must not be scaled.




Reduced axle hole


Semi-reduced axle hole


Special axle primtives


Technic castellated bush primitives

Technic primitives   Top

These primitives are various representations of the castellated technic bush. They are orientated with the technic axle hole along the {y} axis and must not be scaled.




Technic bush primtives

Technic primitives   Top

These primitives are usd to construct technic bush parts.




Technic connector primitives

Technic primitives   Top

These primitives are used to contruct technic connector pegs. They are orientated with the technic axle hole along the {y} axis and must not be scaled.




Technic connector hole primitives

Technic primitives   Top

These primitives are used to contruct technic connector peg holes. They are orientated with the technic axle hole along the {y} axis. They must not be scaled in the {x} or {z} dimensions, but the peghole and npeghol families of primitives may be scaled in the {y} dimension.




Technic gear tooth primitives

Technic primitives   Top

These primitives are used to contruct technic gears and racks. Gear teeth are shaped differently depending on the diameter of the gear wheel. These primitives must not be scaled.




Technic Duplo primitives

Top

These primitives represent various components of the Duplo-scale technic parts.



Stud-related primitives

Stud primitives

Stud-related primitives   Top

Each studxxx primitive described below has a matching low resolution stu2xxx primitive, used by the fast-draw mode of renderers - these stu2xxx primitive must never be used in part files. An additional primitive (studline.dat) is used to substitute a single line for studs by the super fast-draw mode of LDraw.


All stud primitives are modelled with the solid disc uppermost, even if designed for the underside of parts (stud3, stud4, stud8, stud11). The origin is at the base of the stud and they extend for 4LDU in the {-y} dimension. To use for the underside, the primitives need to be inverted in the {y} dimension, viz.


1 16   x y z   1 0 0   0 -1 0    0 0 1   stud3.dat

These primitives must not be scaled in the {x} or {z} dimensions. Ideally they should not be scaled in the {y} dimension either, to allow the accurate substitution of chamfered studs by high-quality renderers [but this rule is flouted in the regular brick files, where stud4 is scaled by 5 to generate the underside tube].



Stud group primitives

Stud-related primitives   Top

Stud groups are provided to reduce the size of part files with many regularly spaced studs. The naming convention is stugN-XxZ.dat, where:

  • N = type of stud (regular stud, hollow stud, underside stud, etc.)
  • X = number of studs on the x axis
  • Z = number of studs on the z axis

To prevent an overload of the library with excessive combinations, the numbers on the x and z axis are limited to:

  • 1xZ stugs
  • Xx1 stugs (Due to stud orientation you cannot rotate a 1xZ stud group by 90 degrees to get a Xx1 stud group)
  • XxZ stugs where X = Z

These primitives must not be scaled.



Miscellaneous primitives

Text primitves

Miscellaneous primitives   Top

The section comprises reusable glyphs for constructing text patterns. These primitives may be re-sized.

The naming convention for these primitives is typeffci, where ff is an arbitrary two-letter abbreviation for the typeface, c is the glyph class (u=upper case letter, l=lower case letter, n=number, s=symbol, a=accented letter) and i is the glyph identifier (a-z for the upper and lower case letters, 0-9 for the numbers).

Primitives for ZNAP parts

Miscellaneous primitives   Top

This section comprises primitives for the ZNAP parts, all of which have been modelled and released into the official library.

Arm, Clip and Pin primitives

Miscellaneous primitives   Top

This section comprises miscellaneous primitives that do not fit neatly into any of the other categories. All are highly specialised and represent components of parts which fit together with each other or other standard parts. As such these primitives are not intended to be re-sized.




Last updated 03 February 2018, to include LDraw updates up to 2018-01, by Chris Dee.