LDraw.org Discussion Forums
ldr file format for models - Printable Version

+- LDraw.org Discussion Forums (https://forums.ldraw.org)
+-- Forum: LDraw Programs (https://forums.ldraw.org/forum-7.html)
+--- Forum: LDraw File Processing and Conversion (https://forums.ldraw.org/forum-22.html)
+--- Thread: ldr file format for models (/thread-15601.html)



ldr file format for models - rda100 - 2015-02-16

Hi all.

I want to write a script for Modo that parses the ldr file for exported models. I'll use the info to instance and position parts I've already imported and cleaned up in Modo.
I kind of understand the file format eg
1 72 0.097007982432842255 -8.004612922668457 -59.886787414550781 1 0 0 0 1 0 0 0 1 4282.dat
I understand the 1 and 72 and the 4282.dat, but I'm more used to seeing position, rotation and scale values which the other values don't seem to fit the pattern of (too many numbers).

Anyone care to enlighten me? Would be greatly appreciated.
Many thanks
Rob


Re: ldr file format for models - Roland Melkert - 2015-02-16

The first '1' is the line type (reference)
72 is the color
next 3 numbers are the position
next 9 numbers is the 3x3 orientation/scale matrix.
and 4282.dat is the 'thing' you need to render/process at the given location/orientation using the given color.

See also

http://www.ldraw.org/article/218.html

Hope this gets you started.


Re: ldr file format for models - rda100 - 2015-03-10

Just jumped back onto this..

Thanks Roland.
I understand a bit more now and should be able to process those lines in Python.
One question though. Is there any way to know the starting orientation of a lego part? I have a library of parts that I have cleaned up and the idea is to read the ldr file and use parts from my library rather than the ldraw parts. The only issue is that my library parts need to line up with the starting position of the ldraw parts, otherwise it will all be a bit messy.

One solution is to import each part I'm using through the Blender plugin and use that as a reference to re-align by hand. But it would be much more efficient if I could read and process the ldr files to figure it out.
Many thanks
Rob


Re: ldr file format for models - Steffen - 2015-03-10

the starting orientation of a part is the one in its .dat file.

for example, a line from 0/0/0 to 1/0/0 is just there.

there is no other information source about e.g. a different rotation or positioning of a part.

a part is where it is. all about it is coded in its .dat file.

there is an ongoing discussion if we should add such positioning info to our syntax,
so we are able to change that default orientation and positioning even when a part has become official
without having to touch its geometry. however, that syntax has not yet been agreed on, or implemented:
http://forums.ldraw.org/showthread.php?tid=15022&pid=15022#pid15022


Re: ldr file format for models - Roland Melkert - 2015-03-10

There is some human logic to the origin/rest rotation of most LDraw parts. But I don't think you could use those rules to automate conversion transformations.

Far as I know the only thing you can correct for automatically is the negative y axis. This is done by rotating e.g. 180 degrees around the x axis.

Other differences you will have to put in some kind of pep part transformation look up table I guess.