File Format (draft)

All LDraw commands consists of a single line of text. The first word on each line identifies the command. This word should be a natural number, and will in the following be identified as the command index. Lines that doesn't start with a valid command index should be ignored.

LDraw accepts the following commands:

In addition to that, LDraw II accepts:

Colours are referred to using colour indices.

Meta commands

The meta commands for LDraw are all the commands that are not directly related to drawing. They have a common command index, 0, and the individual meta commands are identified by the keyword that follows immediately after the command index.

File name

Only implemented in LDraw II (and in the LDraw File Splitter).

Command index:
0
Keyword (case insensitive):
FILE
Parameters:
A file name.
Can appear:
As the first command in a file.
In multi-part DAT (MPD) files marking the start of a new model.

A few examples:

   0 FILE 3412p12.dat
   0 FILE mail_van.dat
 

File names are trimmed to the format known from DOS (max. 8 characters, ".", max. 3 character), and converted to lower case according to the rules for Latin-1 encoded characters.

Title

Command index:
0
Keyword (case insensitive):
TITLE
Parameters:
The title of the model.
Can appear:
Anywhere. Only once.

If the first line in a model file is a comment (command index 0, no known keyword), the text of the comment will be interpreted as the title of the model.

Step

Command index:
0
Keyword (case insensitive):
STEP
Parameters:
None.
Can appear:
Anywhere. Any number of times.

This command is used to mark the end of a step in building instructions. If the model file isn't terminated with a step command, LDraw appends one.

Clear

The behaviour has changed from LDraw to LDraw II. Previously the drawing area was simply erased.

Command index:
0
Keyword (case insensitive):
CLEAR
Parameters:
None.
Can appear:
Anywhere. Any number of times.

Clears the drawing area of everything drawn by the current model file and its sub-models.

Keywords

Introduced in connection with LDraw II.

Command index:
0
Keyword (case insensitive):
KEYWORDS
Parameters:
A comma (,) separated list of keywords. Case insensitive. Multiple spaces are counted as a single space. Leading and trailing spaces are ignored. Empty keywords are ignored.
Can appear:
Anywhere. Multiple times.

A few examples:

   0 KEYWORDS Town, Castle, weapon
   0 KEYWORDS Train, 9V, wheel
 

Include LDraw file

Command index:
1
Parameters:

A few examples:

   0  4  10 10 0  1 0 0  0 1 0  0 0 1   car.dat
   0  9  0 20 10  0 0 1  0 1 0  -1 0 0  minifig.dat
 

Draw line

Draw triangle

Draw quadriliteral

Draw conditional line

Include LDS file

LDraw II only. - Likely to change.

Command index:
6
Parameters:

Draw (partial) cylinder

LDraw II only.

Draw negative cylinder

LDraw II only.

Draw (hollow) box

LDraw II only.

Command index:
9
Parameters:

If the wall thickness is "-", a solid box is drawn, otherwise there is a hole into the box on the side marked by the first two edge vectors.

Terms

command index
The first word in a command. A natural number.
word
Sequence of non-space characters terminated by a space character.

-- 

Jacob Sparre Andersen.


Latest update: 27th of July 2001