MLCad, Michael Lachmann’s model editor for Windows, added its own commands to LDraw files, and many other programs read them. This page follows the MLCad format specification, version 2.0 of June 2004, which covers MLCad 2.12 and later, and an examination of the MLCad 3.40 program. The specification allows other developers to implement the commands. Coordinates, colours and the nine matrix numbers are written as in a type 1 line. The version history says that from version 1.9 MLCad accepts meta commands in upper case only.
ROTSTEP
A form of STEP, taken partly from LDLite, that also turns the view.
Drawing stops at the line. To make the turn itself visible as a step, a plain
0 STEP is put just before it. The angles are in degrees, from −360 to
360.
| Line | New view matrix, where R is built from the angles |
|---|---|
0 ROTSTEP x y z or … REL | Each view’s default matrix × R. |
0 ROTSTEP x y z ADD | Each view’s current matrix × R. |
0 ROTSTEP x y z ABS | R alone; the views’ own angles are ignored, so all views show the same. |
0 ROTSTEP END | Return to the views’ original angles. |
With s1, s2, s3 the sines and c1, c2, c3 the cosines of the x, y and z angles, the rows of R are:
c2*c3 -c2*s3 s2
c1*s3 + s1*s2*c3 c1*c3 - s1*s2*s3 -s1*c2
s1*s3 - c1*s2*c3 s1*c3 + c1*s2*s3 c1*c2
ROTSTEP.Hiding, ghosting and skipping
| Line | Meaning |
|---|---|
0 GHOST command | The LDraw or MLCad command that follows on the same line counts only when the containing model is the main model; in a sub-model or part it is ignored. |
0 MLCAD HIDE command | The command is hidden while editing; viewing mode ignores the hiding. From MLCad 3.10. |
0 MLCAD SKIP_BEGIN … 0 MLCAD SKIP_END | MLCad does not load these two lines or anything between them. The section holds ordinary LDraw lines that stand in for an MLCad object in other programs. |
MLCad 3.40 writes and reads the ghost prefix as 0 GHOST. The MLCad
support script supplied with LDCad looks for 0 MLCAD GHOST.
Groups
| Line | Meaning |
|---|---|
0 GROUP n name | Declares a group of n commands. Groups do not contain groups. |
0 MLCAD BTG name | The line that follows belongs to the group name. |
View images
| Line | Meaning |
|---|---|
0 BUFEXCHG letter STORE | Saves the image of the view in the buffer A to Z. |
0 BUFEXCHG letter RETRIEVE | Restores it. The command is ignored when the model is used as a sub-model. |
0 BACKGROUND file | A picture behind the model, optionally with a path; a later line replaces it. Quotes are recommended and allow spaces; MLCad 3.40 writes them. |
The specification’s description speaks of eight buffers, while its syntax and the
3.10 release notes give the 26 letters. MLCad 3.40 also writes the older
0 CLEAR, which clears the view, and 0 WRITE text.
Rotation points
| Line | Meaning |
|---|---|
0 ROTATION CENTER x y z "name" | A custom rotation point in model coordinates, with a unique name. A model may have several. This is the form in the specification. |
0 ROTATION CONFIG id visible | The point in use: 0 the part’s origin, −1 the part’s centre, −2 the part’s rotation point, −3 the world origin, 1 upward the custom points in the order of their lines. visible 1 shows the point, 0 does not. |
0 ROTATION AXLE | Reserved. |
Divergence from specification
MLCad 3.40 writes an extra integer before the name:
0 ROTATION CENTER x y z m "name". m is the
“Modifyable” box of the point’s definition dialog: 1 lets a shown custom point be moved
on screen, 0 does not. The 3.40 reader needs all four numbers and discards a line
without them, so a line written exactly as the specification gives it is not loaded.
It keeps at most 50 characters of the name, and ignores a CONFIG
identifier that is beyond the points defined.
Generated objects
Springs, hoses, belts, arrows and plates are stored as one command with their settings,
followed by a SKIP_BEGIN section that draws them with standard LDraw lines.
In the table c is a colour, pos three coordinates and
rot nine matrix numbers.
Line after 0 MLCAD | Settings | Since |
|---|---|---|
SPRING c pos rot H R D SD TR BR | Total height; revolutions, not counting top and bottom; diameter; thickness of the material; revolutions at the top; revolutions at the bottom. | 3.00 |
FLEXHOSE c pos rot b bcp e ecp n first inner dl | Begin point, its control point, end point, its control point (three numbers each); number of intermediate parts; file name of the first part; file name of the intermediate part (neither quoted nor containing spaces); dl asks for a line along the centre. | 3.00 |
RUBBER_BELT c pos rot XD YD R1 R2 D P CY | Offset of the second wheel in x and y; radius at the origin; radius at the second point; thickness; precision; CY 1 builds it from cylinder primitives, otherwise from lines and quadrilaterals. | 3.00 |
ARROW c pos rot w1 w2 L1 L2 D R T S CP CI | Width of the pointer; width of the indicator; total length of the pointer; indicator length of a straight pointer; distance from the end of the pointer back to the start of the indicator; radius of a round arrow; T 1 straight or 2 round; S 1 to 3 sections; colour of the pointer; colour of the indicator. | 3.10 |
PLATE c pos rot W L H | Width, length and height of a plate or brick of free size. | 3.10 |
MLCad 3.40 writes these with the same numbers of fields. It also handles the
SYNTH blocks of LSynth,
added in 3.10.
Standard extensions in MLCad
MLCad 3.40 writes MPD
0 FILE lines, 0 BFC INVERTNEXT and
0 !COLOUR definitions with
CODE, VALUE, EDGE and ALPHA.
Its release notes say that since version 2.00 back-face culling lines are kept but
have no effect on drawing.
MLCad.ini
The settings file of MLCad 3.00 and later is not an LDraw file, but other programs read
parts of it. A line starting with ; is a comment and
[NAME] starts a section.
| Section | Lines |
|---|---|
[HATS], [HEAD], [BODY], [BODY2], [NECK], [LARM], [RARM], [LHAND], [RHAND], [LHANDA], [RHANDA], [LLEG], [RLEG], [LLEGA], [RLEGA] | Choices of the minifigure generator: "name" "file" flags matrix offset, where flags is always 0, matrix is nine numbers and offset three. An empty file name is an element that is left out. |
[SCAN_ORDER] | n = SHOW path or n = HIDE path, the path optionally quoted: the order in which library folders are searched and whether their parts are listed. P, PARTS and MODELS must be present. |
[LSYNTH] | %PATH = path for the program, and title = command menu entries, such as RIBBED_HOSE = SYNTH BEGIN RIBBED_HOSE 16. |
Bricksmith reads the file for its own minifigure generator and LSynth menu. It skips
blank lines and comments, ignores the display name and the flags of a minifigure
entry, drops entries with an empty file name or a file already listed in the section,
and sorts the rest. Of [LSYNTH] it uses only lines of the form
number - title = SYNTH BEGIN type …,
the title without spaces, and shows just those types.
Sources
- MLCad – the author’s site, with the MLCad format specification 2.0, the MLCad 3.40 program, its help and release notes
- Bricksmith source –
MLCadIni.m