LDraw Files, Line Endings, and an Ecosystem Inventory

The general LDraw File Format specification is silent on the matter of line endings, but the File Format Restrictions for Official Parts requires DOS/Windows (“CRLF”) line endings. A recent discussion caused me to become curious whether there are really any contemporary compatibility reasons for this recommendation. So, I decided to take an inventory of LDraw programs to see which, if any, had trouble opening files formatted with Unix (“LF”) line endings.

Here is a simple sample model, Test.ldr. It was created with Bricksmith, which outputs files with DOS line endings per the official file format restrictions. I used a text editor to convert the line endings to Unix format.

What programs can read the test model?

Bricksmith 2.3.1 can do it.

LDView 4.1 can do it (with no warnings or errors).

LPub 4.0.0.4 can do it.

L3Lab 1.3 Beta can do it.

ldglite 1.0.18 can do it.

Mac Brick CAD 3.0b1 can do it.

BrickDraw3D 0.5b can do it.

LeoCAD 1.75 for Linux can do it.

LeoCAD 1.75 for Windows can do it.

LDraw Design Pad 1.5.7 can do it.

MLCad 3.2 can do it.

LD4DStudio 1.1 can do it.

LDLite 2.4 can do it.

SR 3D Builder 0.4.5.7 can do it.

LEGO Digital Designer is not strictly part of the LDraw system of tools, but LDD can import it, too.

Command-line tools like L3P 1.3LDTrim 1.1, and LSynth 3.1 can do it (there’s nothing for LSynth to synthesize in this case, of course).

l3p Test.ldr → Test.pov → povray Test.pov → Test.png
ldtrim -in Test.ldr -out Test-trim.ldr
lsynthcp Test.ldr Test-synth.ldr

As a sample of Philo’s LDraw tools for part authors, I modified some of the example files included with Coverer to use Unix line endings.

coverer arc1.dat arc2.dat myarcoutput.dat

The program ran without any trouble.

James Jessiman’s original LDRAW and LEDIT programs (downloadable here) can’t do it – but they’re worth celebrating anyway, so here’s a screenshot of LEDIT looking at the DOS-formatted version of the test model:

I could not find a downloadable copy of LDAO (LDraw Add-On) to test. According to the discussion that inspired this inventory, it too is at least partly dependent on DOS line endings.

With the exception of the inimitable original, none of the many LDraw programs I could test had any trouble interpreting files formatted without DOS line endings.

My conclusion is that the official part file format recommends DOS line endings solely for backwards compatibility with the program that inspired the system. This is not bad, but it’s worth recognizing. As long as there is no inconvenience to other programs or their users, I see no reason to abandon this situation. We have a format that preserves compatibility with older components, and tools that are robust enough to understand reasonable exceptions to the format.

Anyway, here’s a hearty pat on the back for the folks who have made so many nifty ways to play with virtual bricks.

Posted on Friday, January 8th, 2010. Tags: .

2 Responses to “LDraw Files, Line Endings, and an Ecosystem Inventory”

Posted by Bryan Bishop on Saturday, January 9th, 2010 at 1:18 AM.

Thanks for this detailed review. A while back I put some time into
integrating some code with pyldraw to play with python, legos and
LDRAW files all at once. It was more than worth it. Anyway, keep me
in the loop. :-) – Bryan http://heybryan.org/

Posted by Arnold on Thursday, November 3rd, 2011 at 11:42 PM.

I was looking to see if anyone built a Death Star yet, got all the tools to do it myself. not sure if I need it that badly.

one of my first Lego scenes, all free software!