Take the 2-minute tour ×
LEGO® Answers is a question and answer site for LEGO® and building block enthusiasts. It's 100% free, no registration required.

I've seen some pretty neat applications using customized XML formats. There is a Musical Notation XML so that a user can create sheet music on XML. With the right software, that XML can be converted to ACTUAL sheet music, and other plugins even convert this XML to a MIDI output that plays the music.

I'm wondering if there is an XML format for Lego? I would assume it would follow a procedural output where Step 1 is take a 2x2 piece and attach peg Top-Left to 4x1 piece bottom slot. Or something similar.

Just wondering... if there isn't, I feel like there should be. With a Javascript app written for it you could have people converting Lego instruction books to XML or creating custom instruction books with walk-thrus available with a Javascript app.

share|improve this question

2 Answers 2

Yes, there is LXFML - which is if you like an "offical" XML format for LEGO models - in that it's produced and maintained by The LEGO Group.

The .LXF format used by LEGO Digital Designer is a compressed archive containing a thumbnail in .png format and a model definition file in LFXML.

As I noted in the answer to that question, the LDD team have shared both the documentation and XSD for validating this.

Within the definition, there is scope for a <BuildingInstructions> element that can contain one or more <BuildingInstruction> elements. These in turn contain <steps> which reference one or more parts or contain sub-steps:

<BuildingInstructions>
  <BuildingInstruction name="b6206_" cameraRefID="4">
    <Step name="b6206_s1">
      <Step name="b6206_s2">
        <PartRef partRefID="0"/>
      </Step>
      <PartRef partRefID="1"/>
      <PartRef partRefID="2"/>
    </Step>
    <Step>
      <PartRef partRefID="3"/>
    </Step>
  </BuildingInstruction>
</BuildingInstructions>

Note that the <PartRefs> are Ids to parts in the <Model> elements, which define the actual element, colour and orientation.

The default steps created within LDD have been known to be a little hit and miss, adding multiple elements at once and not always visibly or in a valid order (although that may have improved since I last used it for step creation).

share|improve this answer
    
Ah, very good! I didn't realize there was documentation on LDD files, and that it came closer than .ldr files to what randomblink was asking for. I'll go ahead and edit my answer to acknowledge this. –  HaydenStudios Aug 6 at 18:12

As Zhaph - Ben Duguid said, there is the .LXFML format which is basically an XML document detailing a LEGO model. Another format you might find of use if the .ldr format. .ldr files are used in various LEGO virtual building programs that make up what's called the LDraw system of tools. As an example of the .ldr format, this:

Simble brick assembly

Can be generated by pasting this into a text document and renaming it .ldr:

0 Brick test

0 Name: Brick test.ldr

0 Author: HaydenStudios

0 Unofficial Model

0 ROTATION CENTER 0 0 0 1 "Custom"

0 ROTATION CONFIG 0 0

1 4 50 0 0 1 0 0 0 1 0 0 0 1 3001.dat

1 7 50 -8 0 1 0 0 0 1 0 0 0 1 3020.dat

1 4 50 -32 0 1 0 0 0 1 0 0 0 1 3003.dat

1 4 50 -56 10 1 0 0 0 1 0 0 0 1 3009.dat

0

All LDraw applications rely on having a base LDraw installation to refer to which contains files for 3D models of all LEGO parts available in the LDraw parts library. If you wanted to write a Javascript that interprets LDraw models, you'd need it to have an LDraw parts library stored somewhere to refer to, such as on a server.

Each tool in the LDraw system of tools has its own "actions" that it injects into an LDraw file when you edit it. One such program, LPub, is specifically designed for making instructions for models constructed using any LDraw-compatible tool:

LEGO Car in LPub

It allows you to set up each page, and saves your setups for each page into the LDraw file so that it can be read by any program that knows how to read LDraw files and LPub's formatting.

This and the .LXFML format are the only two file formats I know of that are along the lines of what you described. One potentially deciding factor in which format to choose is the different ways they handle instructions. For LDraw files, you have to manually make the steps as you make the models, whereas LDD automatically generates the instructions. While this can save the builder a lot of time, the order in which the pieces are added may not make as much sense as if they were made manually. Whether this is a pro or con is really a matter of personal preference.

Altogether, though, I'd personally recommend using LDraw files due to LEGO Digital Designer's relatively limited part library, as well as the fact that the former is generally more favored among the late teen and AFOL community.

share|improve this answer
1  
Actually, I stand corrected - LFXML does include a Building Instruction element, made up of one or more steps. –  Zhaph - Ben Duguid Aug 6 at 19:34
1  
Thanks for the clarification, I've edited my answer and removed the false statement that it doesn't. –  HaydenStudios Aug 7 at 0:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.