Lasse D

Stud.io 2.0 LDraw export irregularities/oddities

Recommended Posts

I am trying to get an overview of the features, irregularities and oddities of the stud.io 2.0 export to LDraw. (File -> Export as -> Export a LDraw)

It is for the upload functionality of BrickHub.org since many of the submissions are made this way.

This is the list I have compiled so far:

  • The extension will be ".ldr" even though the content seems like that of an ".mpd" file. Is this an error or a feature? Right now I'm treating it as an error and will make a "Change to .ldr"-functionality if submodels are detected.
  • Proper use of "0 NOFILE". It seems like stud.io uses "0 NOFILE" lines instead of "0" lines. Does anyone know the proper use of these lines? Should I make a function to replace "0 NOFILE" with "0"?
  • Decimal precision. Stud.io uses six decimals on all positions and matrix coordinates, so instead of "0" it will output "0.000000". This would not have been much of a problem if it were not for some precision issues. Right now I see a lot of lines in the order of "0.000080" and "0.001234" where "0" is expected. I will make a function to fix this in BrickHub.
  • Suffixes in submodels. From MLCad I expect that submodels have ".ldr" or ".dat" as suffixes in both "0 FILE xxx.ldr" and "0 Name: xxx.ldr" lines. This only happens in stud.io if you remember to add ".ldr" to the names of the submodels. I will have to update BrickHub so it also considers submodels without this suffix as "top level sub models".
  • Additional spacing in "0 Name:" lines. For some reason stud.io inserts two spaces after colon on these lines. I expect this to be a minor bug.
  • Missing authors. Stud.io adds "0 Author:" lines without authors. This is unless you import the model from LDraw - then the author is remembered, but additional spacing is present after the colon.
  • "0 NumOfBricks:  xxx" lines right before content lines is added. It seems to compute the number properly, although there also here is an additional space.
  • Missing "ROTSTEP". Stud.io seems to not only miss rotation steps, but also strip rotation steps from imported models. To add functionality to create rotation steps in BrickHub might be a big task. Would anyone be interested in using it?
  • Additional "0 STEP" lines. If you import an LDraw file with "0 STEP" as the last line of a submodel, then an additional "0 STEP" will be added. It seems like stud.io simply adds "0 STEP" lines without checking for existing lines first.

Any thoughts, comments, or other features?

Share this post


Link to post
Share on other sites

The LDraw standard is a bit fuzzy around the edges.

File extension, from the specifications: “All LDraw files carry the LDR (default), DAT or MPD extension.”  It is not said that MPD contents should always have an .mpd extension.  Treating .ldr files as potential MPD files is the safe path.

“0 NOFILE” is only required to separate non-LDraw contents at the end of a “file” (properly, an “embedded file”), but it may be used to end any “file.”  Moreover, “0” does NOT end an “embedded file,” it’s just a useless empty comment.  See the specs.

Also, it’s not said whether a “file”/“model” in an MPD should have or not an extension.  It’s just said “model” or “name of the LDR file.”  The extension may or not be part of a file’s name.

“0 ROTSTEP” is an MLCad unofficial meta command (list of unofficial meta commands).  You can check the official meta commands here.

In short:

  1. Don’t use ONE application’s interpretation of the specs, use the specs.
  2. As the saying goes: “Be conservative in what you do, be liberal in what you accept from others.”

Share this post


Link to post
Share on other sites

Some notes:

ldr, mpd and dat are all correct LDraw extensions. The difference is in their usage guide lines:

.dat for parts

.ldr for single models

.mpd for model with embeded supmodel/parts.

In practice a parser/loader should not use the extension to do something specific, it should only use the content of the text file.

 

0 NOFILE Is optional, you could also just use the next 0 FILE .

Anything after a NOFILE should be ignored until a new FILE meta is found.

 

Also "0 NumOfBricks" is not an official meta.

 

Share this post


Link to post
Share on other sites

Those are very good observations. The "0 NOFILE" directive should have been for separating FILE-sections, but it seems like it has been interpreted differently by various vendors. I am currently ignoring it and simply using either a "0 FILE" or "0 Name:" to interpret the start of a new subfile. 

Both .ldr, .mpd and .dat files are treated the same way, but I am considering to show warnings to highlight when things are not going according to what is expected. Would it be appropriate to show a warning when multiple subfiles are in a single .ldr file?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.