Jump to content

LDR Importer


le717
 Share

Recommended Posts

LDR Importer


LDR Importer is an Blender 2.6 importer script for models created in the LDraw Model (.ldr, .dat) format. There are currently three developers working on this, with myself as the lead developer.

 

 

History


In early October 2012, I came across a

LDR Importer script created by David Pluntz. However, it was highly broken and did not work at all, as it was written for Blender 2.5(and (ported from a Blender 2.3 script), and the Python API had changed in Blender 2.6. I contacted @JrMasterModelBuilder, who made corrections to the script, and after I made a few more minor changes, I released a working, usable version of the script. All throughout the rest of 2012, JMMB and I continued to try to maintain the script and get it on a good, stable, completely usable order, releasing a version upon almost every stable release of Blender. In January 2013, after I was contacted by someone who provided a Linux patch for the script, I uploaded it to GitHub for any and everyone to work on.

 

Fast forward to August 28, 2013. The script had been on GitHub for almost 10 months, and there had been no release for February. I tried to work on it, but the Blender API is very confusing and poorly documented, so I was very limited in progress. Suddenly, I received a pull request for the script by Banbury, who clearly wanted to help develop this script! A few days of pull requests and cleanup/bug fixes later, the LDR Importer finally reached version 1.0, which I called the Banbury Edition, because of his generous contributions to the project.

Not long after that, I received another pull request from Tribex, who also wished to help with the script. About a month a half and many changes later from all the team members, LDR Importer v1.1 was released, with even more exciting changes contributed by everyone.

 

Downloads


Features


This list is by no means complete. There may be features I have forgotten to add.

  • General
  • Supports all versions of Blender 2.67 onward
  • Automatically preserves installation path to LDraw Brick Library through use of a configuration file
  • Attempts to detect installation path to LDraw Brick Library (Windows only, can be expanded to other platforms if data can be supplied)
  • Non-programmer understandable error messages are thrown for the majority of errors
  • Import on any scale (default: 0.05)

     

  • Library & Models
  • Fully supports library folder structure, including unofficial, p/48, and p/8 folders
  • Supports models in .dat and .ldr format; Multi-part DAT (.mpd) and Bricksmith models do not work properly.
  • Ability to choose between high-resolution, low-resolution, and normal-resolution primitives
  • Model optimization option available by default to clean up the mesh, in addition to using the original mesh

     

  • Colors
  • Uses LDConfig.ldr for color list rather than internal list, providing up-to-date and accurate colors
  • Supports most of the LDraw colors for Blender Internal, including transparent, chrome, pearlescent, rubber, and metal
  • Experimental support for Cycles Engine materials
  • Automatically detects render engine and uses the appropriate materials
Edited by le717
Link to comment
Share on other sites

Yay! Minifig head exports to ldr files now!

P.S. I can make OS X instrucitons if you want.

Yes, the minifg head now exports.

Please do! I run Windows only, so I could not write OS X instructions myself. Just paste them here or PM me with it, and I'll add it to the Readme upon the next release of the scripts. ;)

EDIT: Perhaps now that's I've released it, someone might be able to figure out how to import alpha colors into Blender... ;P

Edited by le717
Link to comment
Share on other sites

JrMasterModelBuilder

Editing the path to LDraw works the same.

The easiest way to install scripts in Blender on OS X would be to place them here:

~/Library/Application Support/Blender/<BLENDER_VERSION_NUMBER>/scripts/addons/

The "/scripts/addons/" folders probably won't exist by default. Also, as a quick explaination of the "~", it means the home folder on Unix systems, so /Users/<USERNAME> is what it translates to. Also, ~/Library is a hidden folder as of OS X 10.7 so the easiest way to get to that folder would be to open finder and click Go > Go to Folder... and enter "~/Library/Application Support/Blender/"

The scripts will then appear in the addons menu.

To change the ldraw.xml file, go to the place "LEGO Digital Designer.app" was installed (probably /Applications/LEGO Digital Designer.app), right click "LEGO Digital Designer.app" (or control+click if you're don't have right click enabled :?:O_O ) and select "Show Package Contents". Then open "Contents/Resources/" and replace the "ldraw.xml" file.

Link to comment
Share on other sites

Thanks JMMB! I've got it, and am currently adding it into the Readmes.

or control+click if you're don't have right click enabled

What? You have to enable right-click on OS X? Man, the more I hear about OS X, the less and less I'm happy Dad has aways bought Windows, and think that Windows 8 will actually be a nice OS...

O.T.

Nobody start a OS war here. I am just stating my view, and I do not wish to debate with you about which OS is better. ;)
Link to comment
Share on other sites

JrMasterModelBuilder

Thanks JMMB! I've got it, and am currently adding it into the Readmes.

or control+click if you're don't have right click enabled

What? You have to enable right-click on OS X?

Apple mice, yes. It varies with trackpads and third party mice. What confuses me is that some people like it that way. That and the "natural" (read "backwards") scroll wheel direction.

Complaints about default configuration aside, Apple's trackpads are really amazing devices. Their under-leveraged with the system software, but with the Better Touch Tool addon it's insane what gestures you can add to it.

Man, the more I hear about OS X, the less and less I'm happy Dad has aways bought Windows, and think that Windows 8 will actually be a nice OS...

O.T.

Nobody start a OS war here. I am just stating my view, and I do not wish to debate with you about which OS is better. ;)

I think you mean more and more happy?

Link to comment
Share on other sites

I think you mean more and more happy?

Yea, that's what I meant. I typed that incorrectly. :P

Editing the path to LDraw works the same.

Yea, but what do OS X users use to edit plain text files? This is no Notepad++ port for Mac (and their won't be without a complete rewrite), so IDK what to tell them to open it with. I'm thinking more about built-in software than stuff you have to download (although I could mention one, just like I do for Windows...)

Link to comment
Share on other sites

V0.7 of the Blender LDraw Import script is released! V0.6 was a bug fix release, but V0.7 is a feature release! I've added the ability to import bricks from every single folder, including Unofficial bricks! JMMB and ProfessorBrickkeeper also helped me write OS X installation instructions. Get V0.7 from on the Topic Post!

Link to comment
Share on other sites

JrMasterModelBuilder

I think you mean more and more happy?

Yea, that's what I meant. I typed that incorrectly. :P

Editing the path to LDraw works the same.

Yea, but what do OS X users use to edit plain text files? This is no Notepad++ port for Mac (and their won't be without a complete rewrite), so IDK what to tell them to open it with. I'm thinking more about built-in software than stuff you have to download (although I could mention one, just like I do for Windows...)

OS X comes with TextEdit, which is like a Wordpad/Notepad hybrid, so it would need to be open in text mode and not rich text mode. Personally, I rarely use the thing, TextWrangler is a much better OS X text editor.

Link to comment
Share on other sites

Thanks for the OS X apps, JMMB. I'll add that to the readme. ;)

BUG REPORT

Blender 2.6 LDraw Importer V0.7 cannot be loaded in Blender 2.64. Why? IDK, I still have to look at the console messages. No planned bug-fix date has been set. In the mean time, if you have updated to Blender 2.64, download the ZIP archive of Blender 2.63 to import your LDraw models/bricks.

Link to comment
Share on other sites

I've fixed the Blender 2.6 LDraw Import script. I don't have time to explain what I did, plus I did a bunch of other stuff. Just take a look at Readme.html for more info. Get it on the Topic post.

Link to comment
Share on other sites

JrMasterModelBuilder

I've fixed the Blender 2.6 LDraw Import script. I don't have time to explain what I did, plus I did a bunch of other stuff. Just take a look at Readme.html for more info. Get it on the Topic post.

That's cool that you were able to embed the add_utils in the script, that should make it easier to install.

Link to comment
Share on other sites

Hi le717,

First of all, thank you very much for your time and effort. I am a long time 3D designer that just last week found Lego Digital Designer and couldn't figure out how I could export the files to a useable format (i.e. blender). I am using Blender 2.6.4 (aware of previous bug) and followed your instructions in the Read Me very closely. The only issue I am having is that in blender I can't actually check the box for your importer, it refuses to let me select it, so I am not sure what I did wrong as I thought I did it all right. I am using Mac OSX and the only little stumble I had was which part (how much) of line 29 needed to be replaced. I just replaced the parts you had in the " " with my newly created path which is LDRAWDIR = ~/Library/Application Support/Blender/2.64/scripts/addons does that look right? I didn't want to bother you, but after reading that you updated your script to work with 2.6.4 specifically, I can't figure out what I did wrong or why I can't check the box under User Preferences in blender for your script. Any help would be greatly appreciated, thanks and have a great weekend!

PS: I was using your 0.7.1 version that was uploaded 2 hours before I downloaded it so I am sure it was the latest.

Link to comment
Share on other sites

Hi sinthetic! Welcome to RRU! Please stick around for a while!

Thanks for your interest in my Blender 2.6 LDraw Importer. It's always nice to hear from someone who has used my stuff!

First off, Line 29 (LDRAWDIR) should be the path to your LDraw Brick Library. You will need to download the LDraw Brick Library for Mac, and replace Line 29 (only the stuff in " ") with that path. For Windows, the default installation path is C:LDraw. I do not own a Mac, so I'm not sure where LDraw is installed to by default. In the near future, I hope to fix this method of setting the LDraw path from editing the script to doing it from within Blender. The path you typed is where the script itself belongs. I need to get with JMMB (JrMasterModelBuilder) a bit more on making Mac instructions, as well as Linux ones.

Second, when was it exactly did you download V0.7.1? After the initial upload, I released I forgot to change bl_info to make it work with Blender 2.63 (it said 2.64), as well as to reset the LDrawPath line. I reuploaded it late yesterday, and the currently uploaded version is the corrected one.

As for the bug, I'm not exactly sure what is happening. Can you provide some more info? When you load the script into Blender files, and right after you open Blender itself, open the Console Window (Window>Toggle System Console) and the Addons menu. With the addons and console side by side, click the check box once to write text in the console. Click it only once, because clicking it more than once will reprint the info. Whatever prints, please copy that exactly and paste that here. The info basically says why the script cannot be loaded. I'll take a look at it, and see what I can do to fix it. I won't be able to take a look at it tonight or tomorrow, but I'll look as soon as I can. ;)

Thanks!

-le717

Link to comment
Share on other sites

Hi le717,

Thanks for the reply. I do believe I have the latest version of your script (looking at creation date), but I am going to start all over from scratch to make sure I have it right. I think having JrMasterModelBuilder in the mix would be really helpful as I only use Windows at work at home I primarily run OS X, which has a "console" and the "terminal", but they aren't quite the same as Windows so I'm not sure how to get the text you were referring to. After reading your reply I saw something that stood out and may be my issue, the "LDraw Brick Library". I only have what LEGO Digital Designer installs, so I will first start there and then recreate my path. I am sure this is something I have done wrong, it's just a little foreign to me. Thanks again, I will definitely post a reply if I figure out what I did wrong so not to waste your time, and if I still can't get it right I will just wait for when you and JrMasterModelBuilder have time to help me out if you don't mind. Thanks again!

Link to comment
Share on other sites

JrMasterModelBuilder

Since the python script is now a single file, these instructions should be easier.

1. Download the LDraw complete.zip from here: http://www.ldraw.org.../downloads.html and extract it.

2. Take the ldraw folder inside and put it somewhere relatively permanent.

3. In Finder, select the Readme.txt file inside the ldraw folder and from the application bar click File, Get Info.

4. Under General, copy the folder path (ends in "ldraw") listed under Where.

5. Open "ldraw_import.py" in a text editor (TextWrangler, TextEdit, etc.) find the line starting with "ldraw_base" and paste the ldraw path copied in step 4 between the quotes after it.

6. Open Blender and open File > User Preferences > Addons > Install Addon...

7. Browse for "ldraw_import.py" and open it.

8. Find the LDraw imported under the Addons window and click the check mark.

When you load the script into Blender files, and right after you open Blender itself, open the Console Window (Window>Toggle System Console) and the Addons menu.

That feature actually doesn't exist in the OS X version (not sure about the Linux version). To do that, you would need to open Terminal and do the following:


cd "<the folder blender.app is in>"

cd blender.app/Contents/MacOS

./blender

Link to comment
Share on other sites

JrMasterModelBuilder, thank you very much for the info I really appreciate it. I finally figured out what I had wrong. I had already made an Automator key command to copy the file path so I knew that was correct, but whenI pasted it where the original text was on line 28, there was an extra ' which I thought was supposed to be there since it is in the original. I looked at the syntax of other lines and it didn't make sense I tried removing it and BAM! I can now check the box! I could always see the box, it just wouldn't react with a check mark, just stayed blank. I just did a quick import test with blender and it works great!!!! Thank you so much JrMasterModelBuilder and le717!

Link to comment
Share on other sites

JrMasterModelBuilder, thank you very much for the info I really appreciate it. I finally figured out what I had wrong. I had already made an Automator key command to copy the file path so I knew that was correct, but whenI pasted it where the original text was on line 28, there was an extra ' which I thought was supposed to be there since it is in the original. I looked at the syntax of other lines and it didn't make sense I tried removing it and BAM! I can now check the box! I could always see the box, it just wouldn't react with a check mark, just stayed blank. I just did a quick import test with blender and it works great!!!! Thank you so much JrMasterModelBuilder and le717!

You're welcome! You know, last night after I went to bed, I thought about the fact that there may be an extra ' added, I just didn't think about it being in the original script!

Glad to know you got it working. But keep checking back here! We are trying to continue to improve the script as much as we can! :D

P.S. I'll take a look at the script and remove that extra '. I don't want anyone to have any more errors!

EDIT: Fixed the upload. The extra ' has been removed.

Link to comment
Share on other sites

I am happy to announce a new, special version of the SpBlender script, Blender 2.6 LDraw Importer Special BMesh Edition. I've taken the V0.7.1 code and changed it to import LDraw models using BMesh, which basically means you can import models use N-gons (up to a 150-gon, the highest I allowed). This is meant to be a research tool, not for general purpose use. Many programs do not support BMesh, and Blender itself supports it as of 2.63+. If you use the script for 3D work, please contine to use the normal release. Again, this is a research tool. I have no plans to make it part of the normal script.

Download Blender 2.6 LDraw Importer Special BMesh Edition from here. I've also upload sample Blender 2.64 BMesh models. And if that isn't enough, here is a large (1080p) clay render of a normal and BMesh LDraw 3001.dat

normal-bmesh-compare-clay.png



Enjoy the research.

Link to comment
Share on other sites

Yes, everything is working very well right now, thanks again guys! I just need to learn blender more, I ordered their Blender Inside Out DVD, I know many applications, just not blender. It has so much power for a free app, I had to dedicate some time to it. I used your LDraw import to make a really crude LEGO rubber duck splashing into some water simulation in blender, so fun to play with!

I'll check back here more after i have learned blender better so I can utilize everything properly.

-sinthetic

Link to comment
Share on other sites

JrMasterModelBuilder

I am happy to announce a new, special version of the SpBlender script, Blender 2.6 LDraw Importer Special BMesh Edition. I've taken the V0.7.1 code and changed it to import LDraw models using BMesh, which basically means you can import models use N-gons (up to a 150-gon, the highest I allowed). This is meant to be a research tool, not for general purpose use. Many programs do not support BMesh, and Blender itself supports it as of 2.63+. If you use the script for 3D work, please contine to use the normal release. Again, this is a research tool. I have no plans to make it part of the normal script.

Download Blender 2.6 LDraw Importer Special BMesh Edition from here. I've also upload sample Blender 2.64 BMesh models. And if that isn't enough, here is a large (1080p) clay render of a normal and BMesh LDraw 3001.dat

normal-bmesh-compare-clay.png

Enjoy the research.

EDIT: It seems the %7Boption%7D tags are broken, so here is the link to the image.

http://triangle717.f...ompare-clay.png

Is there some advantage to supporting N-gons? Is it necessary to import certain models? N-gons are really bad practice in 3D modeling.

Link to comment
Share on other sites

  • 3 weeks later...

Is there some advantage to supporting N-gons? Is it necessary to import certain models? N-gons are really bad practice in 3D modeling.

First question, no not really. I just made this for research. Second question: Not at all. In fact, the models look worse when imported with the BMesh script. I do not plan on adding this to the normal script. Third part: Um, not always. rioforce and I use N-gons in all our stuff. Example: Add>Mesh>Circle, use 32 vertices. Enter Edit mode, select all vertices, and press F. The entire circle has a one-piece face. :)

BUG REPORT!

Bricksmith LDR models do not properly import. This is due to a different layout of the model. Details are on the topic post.

Link to comment
Share on other sites

  • 2 weeks later...

Thanks for the post, Sega! You did the best post you could, considering that I didn't tell you anything about it. ;P

Three months after the last release, I have updated the LDraw Conversion Table for LDD. Since the last update, Mike has release V4.29 and 4.30 of his table. I have merged his changes into mine. In the process, I have updated the table requirements to LDD 4.3.5, but unlike Mike, I did not remove any bricks, so it theoretically should continue to work with LDD 4.2.5. If anyone has the version and the table does/doesn't work, please let me know.

However, the biggest changes to the table is not related to bricks, it deals with Colors. Mike's color chart, even in the newest release, is completely broken. It is outdated, and uses a bunch of colors that no longer exist. In addition, he has some colors defined twice, which creates confusion when exporting/importing models, kinda like a tangled extension cord. I fixed some errors in the last version, but in this one, I have completely revamped the table. Using LDConfig.ldr Release 9-13-12 (the newest one), I have added new colors, corrected colors, and removed a few older colors (yes, that is contradictory to what I said about LDD 4.2.5, but leaving them would tangle the cord up even more) by adding them to a commented section.

All these changes continue to make this table the best one around, at least for now. I have contacted Mike about this table, and asked about a possible merge with his, so we will see what happens. For now, enjoy leaving the Black-and-White world of Kansas and enter into the colorful world of Oz. ;P

Link to comment
Share on other sites

New update!

Blender 2.65 came out a few days ago, and another bug fix of the LDraw importer is released. I thought for sure it would have broken, since I had to removed old Blender 2.5 Python code in order to support Blender 2.64. but this time, it worked! Nevertheless, I had a few changes to make, so I just released V0.7.2.

No new features in this one (hence the minor version bump), but I did discover that the script can be placed in the scripts/startup folder, thus removing the need to activate it manually, or saving a default.blend with the script. Cool, no?

I've also switched back to LDConfig.ldr for the color definitions. It had trouble locating the other file a few times, although it was present.

Finally, for changes not related directly to the script, I've added separate CSS code to the Readme to remove all the inline code. Also of note: A new Planned Features section, which gives a glimpse of the planned changes.

I've also signed up for the Blender Wiki, and completely updated the Wiki page for the script. You can read it here, although the Readme file looks waaay better than that thing. :P

Download Blender 2.6 LDraw Importer V0.7.2 from the Topic Post!

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.