The questions and answers in this FAQ is mainly summaries of communication in the discussion group lugnet.cad.dev.
The LDraw FAQ will be posted to the discussion groups rec.toys.lego, lugnet.cad, and lugnet.cad.dev.
The FAQ can be downloaded/read at these URL's:
<URL:http://www.ldraw.org/community/memorial/archive/FAQ/>
(hypertext)<URL:http://www.ldraw.org/community/memorial/archive/FAQ/text>
(plain text)jacob@ldraw.org)LDraw is a DOS program that allows you to draw LEGO models, create building instructions for them, etc. - A LEGO-style Computer Aided Design system.
The current edition can generate a sequence of .bmp files (MS-Windows bitmaps), one for each step in a building instruction, from a LDraw .dat file.
You can edit LDraw files with the accompanying LEdit program or with your favourite text editor (the latter is said to be very hard, but I do it anyway. - Jacob).
It's free!
You can download LDraw directly from James' Web site at
<URL:http://www.ldraw.org/jessiman/ldraw/>,
but I suggest that you go through the James Jessiman Memorial
(<URL:http://www.ldraw.org/community/memorial/archive/official>)
where you can get new collections of parts as well. You can also download
LDraw from Bram Lambrecht's LDraw
and LEdit tutorial.
No!
But you can get the source code for LDLite (a Win32 replacement) at
<URL:http://www.gyugyi.com/l3g0/ldlite/>.
MS-DOS. Including DOS in OS/2, Win-95 and Win-NT.
There's no Mac and Unix versions.
But there is one in progress (see section 3).
These documents contains LDraw'n models. Either as data files for LDraw or as processed images:
<URL:http://home16.inet.tele.dk/hassing/l3pgal.html><URL:http://jacob.sparre.dk/LEGO/Byggevejledninger/><URL:http://www.ldraw.org/jessiman/lego/models/jsa/BLKWHT.HTML>
<URL:http://lego.bldesign.org/><URL:http://www.nd.edu/%7Elego/grp2/www/4x4instr.htm>James Jessiman. James passed away July 25th, 1997.
We are trying to continue James' work in the discussion group lugnet.cad.dev (see section 9). Many people are working on modelling
more parts, and Paul Guygyi has written a LDraw clone for MS-Windows.
According to Wouter Kooijman LEGO is very positive and supports the program.
If you can't find the answer here, please ask on the discussion groups
lugnet.cad or
lugnet.cad.dev,
and write a section for the FAQ based on the
response.
Until recently technical discussions regarding LDraw (and other LEGO
related CAD packages) were located on the "LEGO-style Computer Aided
Design" mailing list. This mailing list has been superceded by the
discussion group lugnet.cad.dev. You can
access the discussion group in three ways:
<URL:http://news.lugnet.com/cad/dev/><URL:http://www.lugnet.com/news/mail/>)<URL:http://www.lugnet.com/news/>)<URL:http://home2.swipnet.se/%7Ew-20413/simlego.htm>)<URL:http://www.geocities.com/Eureka/Gold/3269/>)<URL:http://perso.wanadoo.fr/paris.jean-pierre/LD2VR/>)<URL:http://ourworld.compuserve.com/homepages/train_depot/td.htm>)If you want to convert the LDraw .dat file MY_MODEL.DAT
to a sequence of .bmp files;
LDRAW.EXE file
resides.LDraw -MS MY_MODEL.DAT at the DOS
command line.You will find a sequence of .bmp files named
MY_MOD01.BMP, MY_MOD02.BMP ... in the
subdirectory BITMAP.
Yes. The .dat files just have to be stored in the MODELS
subdirectory. You refer to them by the file name (no path specification),
just as with the pieces (whose .dat files are found in the
PARTS subdirectory).
In LEdit:
In a text editor: Start the line with a zero.
I'll list various peoples suggestions.
Jacob
I start with the 3-D view, then go to two of the "normal" views to line the puppy up. If I'm putting a piece in among a bunch of others and my view is obstructed, it helps to turn on the "Stop at cursor" option.
If I'm putting in a piece that needs to go at an odd angle, and there
is already another piece at the same angle, I load the .dat file into a
text editor and copy and paste the line of the first piece. I then load
it into LEdit and move it around.
Sproat
I check a couple of different views to check sometimes. I usually use
James' method: hit down, so that all but the studs are visible. If the
fit is correct, bring the piece up the correct number of moves.
Bram Lambrecht
If you use LEdit, you will have to exit it, to do step 3 to 4/5 in a text editor.
You can find links to the package itself, and to the L-CAD parts
collections at <URL:http://www.ldraw.org/library/updates/>.
The last collection of new parts is from December 1999.
There is a tutorial
for LDraw and LEdit at <URL:http://www.thinkquest.org/library/lib/site_sum_outside.html?tname=205>.
External units:
<URL:http://home2.swipnet.se/%7Ew-20413/ldlaunch.htm>)
<URL:http://jacob.sparre.dk/meyer/LEGO/V%E6rkt%F8j/#landskaber>):<URL:http://jacob.sparre.dk/meyer/LEGO/V%E6rkt%F8j/#MPD.Files>):<URL:http://www.math.uio.no/~fredrigl/technic/ldraw-mode/bezier-curve/>):<URL:http://home2.swipnet.se/%7Ew-20413/bmp2dat.htm>):<URL:http://www.el-lutzo.de/lego/files.html>):<URL:http://home16.inet.tele.dk/hassing/l3p.html>):<URL:http://home2.swipnet.se/%7Ew-20413/ldd.htm>)You should always remember to have a look at the overview of LDraw
resources at the James Jessiman Memorial (see <URL:http://www.ldraw.org/community/memorial/archive/ldraw>).
The first three numbers determine the position along the screen X axis. The first one is how much the model X axis affects the position. The next one is how much the model Y axis affects the position and the last one is how much the model Z axis affects the position.
So:
Screen X = Model X * First number +
Model Y * Second number +
Model Z * Third number
The next three numbers are for the screen Y axis and finally the last three are for the screen Z axis. I.e.:
Screen Y = Model X * Fourth number +
Model Y * Fifth number +
Model Z * Sixth number
Screen Z = Model X * Seventh number +
Model Y * Eighth number +
Model Z * Ninth number
The screen Z axis is not really drawn. It is only used to determine which piece is visible and which piece isn't.
The screen X axis goes to the right, the Y axis goes down, and the Z axis goes away from you (into the screen).
You have to insert a step command at the end of the .DAT file. [This problem should have been solved in the present version of LDraw/LEdit.]
Stop editing your .DAT files in Notepad! Or at least, stop making mistakes when you do edit them. [Says Steve]
Run MAKELIST to regenerate the file PARTS.LST. [This problem should have been solved in the present version of LDraw/LEdit.]
There are two possible reasons for this. Either
In the first case, you will have to reinstall all of LDraw (run the
installation programs with the option -y to speed up the
process). In the latter case, you should try to run LEdit from the
catalog LDraw and LEdit are installed in.
.DAT files are text (yes, you can edit them in EDIT or Notepad or your favourite text editor). Each line is a single command, and each line is independent. The commands are (mostly) very simple, there are only a few different commands. Specific commands are identified by the first number on the line, which is called the line-type. The contents and format of the rest of the line depend on the line-type. I do not know of any length-limit on command lines.
Each line in the .DAT file is a single command. The first number on each line is the line type, valid values are 0 through 5, with the following meanings:
If the line type for a line is not a valid value, the line is ignored.
Meta-commands require a keyword to follow the line-type. These keywords must be in all-caps, and you should assume that if the meta-command doesn't require more information, you shouldn't give it any additional information.
Here is a complete (as far as I know) list of LDraw drawing- and meta-commands:
And here are the details of each command. Meta-commands are listed first, with the "real" commands after. The command-names are wholly made up by me, I don't have any "official" names for these things.
0 title-text0 STEPldraw\bitmap directory. These two
effects are controlled by the -M command line option (see
ldraw.doc for info on -M).0 WRITE message-text0 PRINT message-text0 CLEAR0 PAUSE-M command line option.0 SAVE-M command line
option.1 colour x y z a b c d e f g h i part.datp\, parts\, or
models\ subdirectories (under the ldraw\
directory). They may also be located in the current directory. James
has arranged the directories so that p\ contains elements
that are intended to be used as part of elements (such as
stud.dat). The parts\ directory contains
finished parts, ready to be used in construction models. And the
models\ directory contains construction models.2 colour x1 y1 z1 x2 y2 z23 colour x1 y1 z1 x2 y2 z2 x3 y3 z34 colour x1 y1 z1 x2 y2 z2 x3 y3 z3 x4 y4 z45 colour x1 y1 z1 x2 y2 z2 x3 y3 z3 x4 y4 z4
1___________2
/ \
/ \
6/ \3
|\ /|
| \ / |
| \5___________4/ |
\ | | /
\ | | /
\|___________|/
1___________2
/ \
/ \
6/ \3
|\ /|
| \ / |
| \5___________4/ |
\ /
\ /
\_____________/
Colours are outlined in LEDIT.DOC. Two special values are 16 and 24. 16 is the 'current colour', i.e., whatever colour was specified on the type 1 line which caused the current line to be executed. Colour 24 is a complementary colour to the current colour, usually the bright/dark complementary shade. So if the current colour is dark blue, colour 24 would give bright blue.
Also, colours 256 through 511 are dithered. So if you want to combine colours J and K, figure your colour value as
colour = (J * 16) + K + 256
The complementary colour of J is used as the complementary colour of the dithered value. So you can control the edge colour (somewhat) by switching J and K.
Line type 1's format is:
1 colour x y z a b c d e f g h i part.datFields a through i are orientation & scaling parameters, which can be used in 'standard' 3D transformation matrices. Fields x, y and z also fit into this matrix:
| a d g 0 |
| b e h 0 |
| c f i 0 |
| x y z 1 |
so that every point (x, y ,z) gets transformed to (x', y', z') :
x' = a*x + b*y + c*z + x
y' = d*x + e*y + f*z + y
z' = g*x + h*y + i*z + z
or, in matrix-math style:
| a d g 0 |
| X' Y' Z' 1 | = | X Y Z 1 | x | b e h 0 |
| c f i 0 |
| x y z 1 |
There are two tools for converting LDraw models to the format of the ray-tracer POV-Ray. L2p is based on Lutz Uhlmann's very detailed parts library, LGEO. It is available for DOS and Linux. L3p is based on the LDraw parts library. Only available for DOS.
Lutz Uhlmann's LGEO tutorial can be found at <URL:http://www.el-lutzo.de/lego/tutorial.html>.
> l2p -i -v -t -l my_model.dat my_modelIt is important that you process sub-models as well, because L2P simply converts a reference to a .DAT sub-model to a reference to a .INC sub-model.
l2p_test.pov):
> copy l2p_test.pov my_model.pov
#include "l2p_test.inc"). It should refer to the
.INC file for your model instead:
#include "lg_color.inc" #include "lg_defs.inc" #include "my_model.inc" |
> povray +L/usr/lib/povray/include/ +Llgeo/ +Imy_model.povThe first
+L refers to the POV-Ray libraries, the second
+L refers to the LGEO library, and the +I
refers to the scene file.
In the windows version instead of writing a long command line, you
need to go to Edit Rendering Settings and add the command line options
(+L).
Use BMP2LDRAW, BMP2DAT or Tore's LDraw vector drawing program (see the answer to question 16) to create a .DAT file with just the image.
Copy the DAT file for the part you are going to add the bitmap to from
the Parts catalog to the Models catalog, and
give it a new name.
Insert the bitmap as a part in the new DAT file. Translate and rotate the bitmap part as appropriate. B
Colour 47 (clear white) works pretty good.
See section 27 for more information on colours.
First check if somebody else are working on the part. You can do that
on the parts tracker (see <URL:http://home.swipnet.se/~w-20413/ttracker/ttracker.htm>).
Steve Bliss, Jaco van der Molen, and Tore Eriksson present different
approaches to creating parts, and Manfred Moolhuysen has some detailed
advice for using the predefined subparts (without studying math). But
first of all, you should check out
which primitives are available (at <URL:
http://www.ldraw.org/community/memorial/archive/FAQ/Primitives_Reference>).
When you have finished the part, you should check it for technical
mistakes with l3p -check,
and then send it to parts@ldraw.org so it can be included
in the L-CAD parts distribution.
Hmm. "Directions for making parts". Hmm. I can't think of directions, so much as advice. I don't really see how there could be a 1-2-3 cookbook approach. But here are some thoughts:
When you model a part, you need to think in terms of vertices, edges and surfaces. Your part-file has to provide one or more commands for each edge and surface. You need to specify these edges and surfaces by the XYZ position of their vertices. So you have to measure out where the vertices are. The trick with lego parts is that they are (typically) built around the familiar sizes of studs and plates (and bricks). So you often measure parts by comparing them to other parts (like simple bricks and plates).
The typical way to start drawing a part is to examine the .DAT file for a similar part. At least, that's the way *I* do it. ;-) Doing an LEDIT xxxx.DAT will let you step through each line in the part-file, so you can see what the effects are. And how other people have built their parts.
Here are some suggestions on what you should check out as you get started:
What kind of instructions/information would you like to see? I'd be happy to answer questions (and I'm sure others would as well), but I don't have time to write up a big list of instructions right now. Tips I can provide, but I hate throwing off a bunch on context-free information which may or may not be relevant.
Tip #1: The LDraw standard for positioning is to center the piece on X=0 and Z=0. Usually, the top of the part (excluding studs) is set to Y=0.
Tip #2: Look for repeated elements in a part, which you can write up as a sub-part file. I find long lists of LDraw commands to be very confusing. Using subparts can shorten the file, and make things more comprehensible. In writing my chain-saw blade, my final version used 10 custom files. I used the inliner utility to combine all these files before publishing.
Tip #3: Use the 0 command-line to insert as many comments as you want. You can always remove them before publishing, if you don't want everyone to see your notes. This can really help to organise long files, making it easier to go back and fix sections later.
Tip #4: Notepad is not very good. Wordpad is better. You may have another editor you like even more.
I can't think of anything else right now. Ask lots of questions.
Steve
Sjaacko
While making a part, I often use different colours so that I can easily see what areas are still to be covered, if a polygon came out right, and which one didn't.
You can find an example at <URL:http://www.ldraw.org/community/memorial/archive/FAQ/25a.gif>.
When everything is done, it's easy to set all to colour 16 or 24.
Tore
Examining the existing part file of a basic lego brick also helps you to understand how part files are made.
Most of them use subparts, handy primitive shapes like cylinders,
circles, disks, and the studs that are on top of or inside the bricks.
You find all the available subparts in the subdirectory
P.
The line:
1 16 0 8 0 -6 0 0 0 -12 0 0 0 6 4-4cyli.dat
means you are including a full cylinder wall, a tube with both ends
open. The other #-#cyli.dat subparts are useful if you want
just a part of a cylinder wall, say 3-4cyli.dat for a 270 degrees
cylinder part.
The numbers 0 8 0 tells LDraw to place the cylinder base
centred at the point (X = 0, Y = 8, Z = 0), just like the placing of
normal parts.
The 9 numbers following represent combined information about the dimensions of the cylinder and its orientation in space. In mathematics it is called a transformation matrix, but luckily for us we can tackle this in a "you don't have to know math" way.
To put it simply:
In this example the cylinder radius is 6 units (= diameter 12). the two numbers 6 are responsible for that. If those two numbers were not equal the result would have been a "squeezed" pipe with an oval cross-section. The 12 says the cylinder is 12 units high or long.
I have worked out a simple way to deal with the orientation of subparts, without getting my mind in a numerical twist:
1 16 0 0 0 6 0 0 0 12 0 0 0 6 4-4CYLI.DAT
This is a cylinder with radius 6 hanging down 12 units from the zero
plane.
You see, no math at all. It also works for all the other subpart types.
Create this file, in the LDRAW\MODELS directory: 0 1 16 0 0 0 6 0 0 0 12 0 0 0 6 4-4CYLI.DAT 0 and name it TEST.DAT. View it in LDRAW and see the result. now change the file in: 0 1 16 0 0 0 6 0 0 0 24 0 0 0 6 4-4CYLI.DAT 0 View the result in LDRAW again. You will see the cylinder is twice as long now. now change the file in: 0 1 16 0 0 0 12 0 0 0 24 0 0 0 12 4-4CYLI.DAT 0 View the result in LDRAW again. You will see the cylinder is twice as wide now. now change the file in: 0 1 16 50 24 20 12 0 0 0 24 0 0 0 12 4-4CYLI.DAT 0 View the result in LDRAW again. You will see the cylinder has been moved to a different spot. Now you have an idea what the numbers do if you change them: position 3,4 and 5 were 50 24 20 and control the insertion point of the subpart. position 6 to 14 were 12 0 0 0 24 0 0 0 12 and control the size of the subpart. Changing the order and the signs of the last 9 numbers turns your cylinder, so it is pointing in another direction. This is what you do in LEDIT. first change file TEST.DAT back in: 0 1 16 0 0 0 12 0 0 0 24 0 0 0 12 4-4CYLI.DAT 0 We set the numbers on positions 3,4 and 5 to 0 0 0, so the cylinder will turn around its insertion point. Start LEDIT, press the ESCAPE-key, press F (stands for file) and L (for load) Type the file name: TEST.DAT. line: 1 16 0 0 0 12 0 0 0 24 0 0 0 12 4-4CYLI.DAT is in the middle of the three lines displayed at the top of the screen. the line above reads START and the line under reads END. Press ESCAPE again, Press T (for turn) and X (for x-axis). Type the angle: 90
On the screen it seems the cylinder has disappeared, but if you press PAGE-UP followed by PAGE-DOWN the cylinder is redrawn in its new position. As you can see the cylinder is laying on its belly now.
First save the file: press the ESCAPE-key, press F (for file) and S (for save). Then open it in your text editor or in windows and cut and paste the line in the file where you need it.
If you turn the subpart around Z instead of X it is turned into another direction. Turning around Y is just like spinning the cylinder around its center, you see no difference at all.
If your file has more than one subpart in it, you can select the one you are going to turn with the PAGE-DOWN and PAGE-UP keys. It must be the middle one of the 3 lines displayed at the top of the screen.
Now try to do something similar with RECT.DAT, make the file
0 1 16 0 0 0 40 0 0 0 1 0 0 0 20 RECT.DAT 0
Just start to play and fiddle a little bit with the numbers on positions 6, 10 and 14, and see what results you get.
M. Moolhuysen
1 0 0.0 0.0 0.0).LDraw looks for .DAT files in the following catalogs, in the order they are listed.
P catalog.PARTS catalog.MODELS catalog.The following list is based on the documentation for LDraw, on discussions on the L-CAD mailing list, and on a compilation of RGB colour values by Todd Lehman (LDraw is not using the RGB values listed here). I have added some <red, green, blue, alpha> codes for rendering transparent parts in POV-Ray and other ray-tracing packages. Most of them are copied from Lutz Uhlmann's LGEO package.
In LDraw colour number 24 refers to a contrast/complement colour for the current colour (number 16).
Notice that complementing is not reversible for colour numbers 6, 7, 14, and 15.
| Surface | Edge |
|---|---|
| 0 | 8 |
| 1 | 9 |
| 2 | 10 |
| 3 | 11 |
| 4 | 12 |
| 5 | 13 |
| 6 | 0 |
| 7 | 8 |
| 8 | 0 |
| 9 | 1 |
| 10 | 2 |
| 11 | 3 |
| 12 | 4 |
| 13 | 5 |
| 14 | 8 |
| 15 | 8 |
LEdit crashes with runtime error 200 on some fast machines. Some delay
routines which use a fixed value to count down just resolve to fast on
these machines. There is a solution to this problem at <URL:http://www.ldraw.org/community/memorial/archive/rte200fx>.
If you can read German, you can also go to <URL:http://www.heise.de/ct/ftp/ctsi.shtml>
and download bppatch.zip, which will do this job for you.
<URL:http://membres.lycos.fr/jmy51/bug/download.html>
has the same explanation, but in French.
The hidden message in this code is "path not found". It occurs if the
path to LDraw contains "long" (more than eight letters) catalog names.
The problem can be solved by moving LDraw to a directory named
C:\LDraw.
No, but you can move the files with a command like this:
C:\LDRAW> move BITMAPS\MODEL-01.BMP D:\Where\I\Want\My\Pictures
Part voting is democratic and is handled by Steve Bliss. Steve is very respected by the group, so sometimes he makes decisions on ideas that don't warrant a vote (or basically gives us the final word). Primitives are handled by a committee.
application/x-ldrawapplication/x-multi-part-ldrawapplication/x-ldliteThe web server jacob.sparre.dk, which hosts
the FAQ has been configured by adding:
AddType application/x-ldraw dat
AddType application/x-multi-part-ldraw mpd
AddType application/x-ldlite ldlite
to the file /etc/httpd/conf/httpd.conf (it's Apache). Most people prefer to use three
letter extensions, so the LDLite line should probably read:
AddType application/x-ldlite ldl
When LEdit breaks down and writes "Runtime Error 216", it is likely to be because your model file contains more than 1000 lines. When you model file is that long it is a good idea to split the model into sub-model, which from the main model looks just like individual LEGO bricks.
Even though I try to, I can't know everything, so please write me, if you have corrections or
additions to the FAQ.
Jacob
<jacob@ldraw.org>
Latest update: 17th of June 2002.