Various Authors, extracted from original LDraw FAQ
[Editors' note: This is not a formatted tutorial. This is a direct copy of the entry in the original
LDraw FAQ 'How can I create a part that is not yet in LDraw?' We feel this question is too long for the
FAQ and needs to be expanded upon more. If you are a parts author and would like to help rewrite these
contents into a yutorial please let Orion Pobursky know.
We would like to expand this section into a collection of standard tutorials, in the 101, 201, 301 format
for skill levels. If you are a parts author, please consider being a part of that effort.]
How can I create a part that is not yet in LDraw?
First check if somebody else are working on the part. You can do that on the LDraw.org
Parts Tracker.
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.
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 LDraw.org parts distribution.
Steve Bliss writes:
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:
-
Study the LDraw language section of the LDraw FAQ. Become very familiar with the formats,
and what they do.
-
Expertise with computer graphics methods is very helpful. You should at least be comfortable with the
concepts of rotating, translating, and scaling, even if you aren't comfortable with the theory behind them.
-
Forget about LEdit, except as a sometimes buggy way of stepping through the part-files you create.
Notepad will be your friend for creating new parts. I also use Excel, LDraw Add-On's Inliner, and the
little Torus Generator I wrote. If you find another tool that is helpful for parts-modelling, I'd like to know!
-
Learn what's in the ldraw\p\ directory. This directory contains a number of subpart files that are
useful in different parts. STUD.DAT is used in almost every LDraw part in existence (and most of
the others use STUD2.DAT). The other files are useful "synthetic primitives", such as rings,
discs, cylinders, and spheres. Some of them are LEGO-specific, such as PEGHOLE.DAT, and some
are very general, such as 1-4DISC.DAT (BTW, the '1-4' means 1/4).
What kind of instructions/information would you like to see? I'd be happy to answer q
uestions (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
Jaco van der Molen writes:
-
I made a drawing on paper of the basic points and started mapping these coordinates.
-
Next I used Excel (yes, MS Excel) to define the coordinates of all other points and combined these into lines and faces.
-
To finish the job, I used Editpad to remove the tabs and replace them by spaces and there I had it!
Sjaacko
Tore Eriksson writes:
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.
When everything is done, it's easy to set all to colour 16 or 24.
Tore
Manfred Moolhuysen writes:
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:
-
The pure value of the numbers represent the dimensions.
-
The distribution of the numbers over the 9 available positions and the fact if they are positive or negative
represent the orientation.
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:
You see, no math at all. It also works for all the other subpart types.
Some examples and detailed instructions:
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