I've moved! Please update your links to point to:

http://www.boatcake.net

This website will remain in existence for archival purposes. If you came here from a link on a forum profile or some other webpage of me, let me know so I can update the link. Thanks!

< Back Home

I made a Python script for Blender 2.4x that imports LDraw (digital LEGO) models. You can download it here.

Features

  • Utilizes Blender's hierarchical object structure, for easy moving and management of parts
  • Uses mesh-linking, so that every duplicate part has the same mesh, but can have different colors and transformations
  • Imports colors from the LDraw header file as materials, complete with raytraced transparency for transparent colors, emissive materials for luminescent colors, and raytraced reflections for chrome, metal, and pearlescent colors
  • Supports parts with multiple colors (stickers)
  • Instead of using primitive substitution like L3P, it can automatically set all round primitives (cylinders, spheres, cones, and tori) to use smoothed normals
  • If smoothing is not enough for you, it can also force models to use hi-res primitives when available
  • Can replace light.dat references with lamps, complete with color from the model file
  • Can scale individual parts to create a seam between pieces
  • Saves preferences for future imports
  • Uses a simple GUI

Here's a simple comparison of output from L3P and from my script. It contains the 64 official LDraw colors.

L3P outputScript output

Recent changes/changelog

  • 1.0
    • Initial release
  • 1.0.1
    • Fixed problems with importing materials from the new ldconfig.ldr
    • Added support for GLITTER and SPECKLE special material syntax
    • Removed setting the ambient light setting from materials

Known problems/bugs/things to improve

  • Models should NOT be considered Game Engine-ready, as the script does not yet support the LDraw BFC syntax.
  • Colors/materials can be drastically improved on. MATERIAL ARTISTS WANTED!
  • Some parts show incorrect transformation (notably 981, 982, 3823)
  • Script is SLOW!
  • Does not yet support MPD files/MPD file syntax.
  • Names mesh/objects to file names, rather than part names. Will probably stay this way.

It should be pretty self-explanatory for Blender users, but here are instructions anyway.

Install

  1. Download and install Blender, the correct version of Python, and LDraw if you haven't already.
  2. Download the compressed script here.
  3. Extract the file if your browser didn't already.
    • Mac: Double-click the downloaded file.
    • Windows Vista: Double-click the downloaded file, select "Extract all files", and select a target location.
    • Windows XP: Right-click the downloaded file, and select "Extract all files".
    • Linux: Double-click the file.
  4. Place the script file into your Blender scripts directory.
    • Mac:
      1. Navigate to where you installed Blender
      2. Right-click (or control-click) on Blender
      3. Select "Show Package Contents"
      4. Select "Go" > "Go to folder", and type in

        Contents/MacOS/.blender/scripts
      5. Click "Go"
      6. Place the script there.
    • Windows:
      1. Navigate to

        C:\Program Files\Blender Foundation\Blender\.blender\scripts
      2. Place the script there.
    • Linux: Place the script in Blender's script directory, usually in

      /usr/share/blender/scripts
      or

      .blender/scripts
      in either your user folder or next to the Blender executable.

Run

  1. Launch Blender.
    • If it was already running during the installation, you'll either need to restart Blender or rebuild the scripts menus. Sometimes both.
  2. Select "File" > "Import" > "Import LDraw...".
  3. Navigate to the .dat file that you wish to import.
    • NOTE: At the moment, MPD (Multi-Part Data) files are NOT supported. Some .ldr files with MPD information will also not work.
  4. Select import.
  5. Choose what options you'd like to use for the import.
    • LDraw dir: THIS MUST BE SET CORRECTLY to your LDraw install path (the directory in which the P and PARTS directories reside).
    • Transform: Transform the model to match Blender's coordinate system. Also scales down models.
    • Smooth: Automatically smooth round primitives (cyl, sph, con, tor)
    • Hi-Res Prims: Force use of high-resolution primitives (from p\48), if possible.
    • Lights from model: Create lamps in place of light.dat references.
    • Seam width: The amount of space in-between individual parts (scales each part to 1.0-seam width)
  6. Click OK.