To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cad.lddOpen lugnet.cad.ldd in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / LDD / 18
17  |  19
Subject: 
Re: LDD to LDRAW Conversion Fixes
Newsgroups: 
lugnet.cad.ldd
Date: 
Thu, 29 Jun 2006 09:36:33 GMT
Viewed: 
25442 times
  
Apologies to anyone who didn't follow this post.  It always bugs me when people
post technical stuff with no explanation, and just expect everyone to 'get it'.
In this case, a lot of people aren't going to be familiar with XML files, so
here's a quick explanation.

The file "ldraw.xml" in the LEGO Digital Designer's "database" folder is a
look-up list for converting LEGO Digital Designer (LDD) parts into LDRAW parts
and back again.  Ordinarily, LDD uses its own ".lxf" file format for saving
models, which you won't be able to read.  Using the look-up list in "ldraw.xml",
it can convert LDD models into ".ldr" files for editing in MLCAD and the like,
and load ".ldr" files back in.

The file is in XML format.  This is a text format with marker tags in to make it
machine-readable.  Each bit of useful data is enclosed by tags.  These tags are
surrounded by 'less-than' and 'greater-than' symbols.  At some point in
computing history, the 'less-than' and 'greater-than' symobls "<" and ">" got
promoted to 'honourary brackets'.  Don't ask me how.

Anyway, a marked-up bit of data looks like this:

   <tag> data </tag>

"<tag>" is the opening tag, and marks the start of the data.
"</tag>" is the closing tag, which marks the end of the data.  Note that it's
the same name as the opening tag, but with a slash at the start.
The useful information is whatever's in between.

An opening tag can also have some parameters (these parameters aren't copied in
the closing tag by the way; that only needs the same name) like:

   <tag name="tag001"> data </tag>

Tags and parameters can have any name you like, so long as the program reading
the XML has been programmed to understand them.
So, for example, the part number entry for the 1x1 tile looks like:

  <geometry tabulaname="30039">3070b</geometry>

This is a 'geometry' tag; the parameter 'tabulaname' is LEGO's part number that
this applies to, and the data part, '3070b', is the LDRAW part reference to use
instead.  The words 'geometry' and 'tabulaname' obviously mean something to LDD,
even if they don't make obvious sense to us.

In XML, a comment begins with "<!--" and ends with "-->".  Everything within
these markers is ignored by the machine reading the file.  So, to 'comment out'
the faulty 1x1 round plate definition, you have to change:

   <remapldraw tabulaname="6141">4073</remapldraw>

to:

   <!-- remapldraw tabulaname="6141">4073</remapldraw -->

(You can use 'find text' and search for the number '6141' a few times to get to
the relevant line).

What this edit does is it makes the opening tag, data and closing tag all part
of one big comment, so it's ignored.  The machine reads the "<!--" part, then
skips along, ignoring the rest of the tags and the data they contain, until it
passes the "-->" at the end of the line.

This should give you enough information to understand how to edit the contents
of the XML file.  There are some more features of XML you may want to know about
too:

1. It's probably obvious by now that you can have lots of tags with the same
name.

2. Line breaks are irrelevant to XML - the text is only laid out on separate
lines to make it easier to edit.  As far as the computer is concerned, it could
all be bunched up on one line.

2. Tags can be nested; you can contain one lot of tags in another - but, they
must be completely contained, closing tags and all, or you get an error.  For
example:

   <outer>
      <inner>
         data
      </inner>
   </outer>

is correct, but:

   <outer>
      <inner>
        data
      </outer>
   </inner>

is really really wrong.

3. Another common mistake is to write "<tag>data<tag>" instead of
"<tag>data</tag>", or simply to miss out some of your closing tags altogether
when they get too deeply nested.  That's why they're often written on separate
lines and indented, so the author can keep track of how many tags deep he is.

4. If a tag doesn't actually have any data, but needs to be present as a
placeholder, it can be written as an empty tag:

   <tag />

or just:

   <tag/>

Note the slash is on the end, and you don't need a matching closing tag.  So,
"<tag />" means the same as "<tag></tag>".


Finally, LDD reads the XML file as soon as you run it - it doesn't wait until
you load or save something.  So, if you make changes, you have to exit and
re-start LDD, then try saving or loading your model again.

And, as with any file editing, make a copy of your original "ldraw.xml" file
under a different name before you start to edit, so you always have the original
to go back to.


Jason R



Message has 1 Reply:
  Re: LDD to LDRAW Conversion Fixes
 
One more tip - if you want to check all your XML is marked up correctly and you haven't made any mistakes, just double-click the file. It'll open in Internet Explorer (unless your name's Christopher and you have a MAC... ;-). You should see a neatly (...) (18 years ago, 30-Jun-06, to lugnet.cad.ldd)

Message is in Reply To:
  LDD to LDRAW Conversion Fixes
 
I've been tinkering with the "ldraw.xml" file in LEGO Digital Designer (LDD), and have come up with the following list of fixes for good LDD/LDRAW conversion. In case you hadn't already discovered, if you append ".ldr" to the end of the file name (...) (18 years ago, 28-Jun-06, to lugnet.cad.ldd, lugnet.lego, lugnet.trains, lugnet.town, lugnet.build) !! 

10 Messages in This Thread:





Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR