The script is still very rough, and with the progression shown it is actually pretty slow. You can turn off the redraws and set zoom_extents to False to have it import much faster. What it does:
import parts as block definitions
create the assemblies and model from block definitions
add materials based on LDraw color definitions
There is still lots to do, but I thought it’d be nice to share the progress so far.
then in the script set your path to where you store the parts
(around line 435):
###########################################
## Set path to where your LDraw library and
## model files are. They should be under
## the same main folder
## Use always forward slashes, also for
## folders on Windows
###########################################
lib_path = "/Users/gijsdezwart/Documents/ldraw"
then a bit lower you will find:
###########################################
## Specify what model to load. Use just the
## file name (including extension)
###########################################
fl : Path = vfiles["10252-1.mpd"]
copy the files you download to the same folder you unzipped to
In the coming days the script will be improved with configuration capabilities and a simple GUI to do so. Until then these instructions by @Gijs should be good.
I usually use a timer for the redraw like this:
(partly pseudo code since I am logging off.)
import time
startTime = time.time()
for i in range(number_of_things_to_do):
# REDRAW every 0.2 seconds
if time.time()-startTime >0.2:
REDRAW (I use sc.doc.views.redraw since it is much faster than rs.redraw)
#reset timer
startTime = time.time()
I do the same thing with counting and presenting % of stuff done too, since I don’t want prompting to slow down fast stuff.
You’re converting the native LDraw file format to 3dm, correct?
I just recently started looking at this too and, from a non-coding workflow, it seem like most people use something like these links to open LDR files:
And then export as STL to use Blender for rendering, but I’ve never done it so I’m not sure how much native LDR info gets lost (probably most of it which is the point of creating a script…).
Also I’m pretty familiar with Studio for custom builds which, if you didn’t know already, can export LDR files. Studio files are IO format but there is not really a database of built sets like LDraw. You can import all the parts for a set into Studio but it then needs to be rebuilt digitally.
The Studio software is maintained and distributed by Bricklink which is a company that was acquired by The LEGO Group (TLG) in 2019.
While there is no “officially” recognized LEGO digital software, TLG buying Bricklink was essentially the nail in the coffin for LDraw software development and it is now no longer actively supported.
LDraw vs Studio vs MecaBricks (online based) for modeling and generating instructions used to be a common debate but Studio has pretty much won the war.
But, of course, the IO file format doesn’t seem to be as open source as LDR.
I am indeed directly importing the LDraw format. The fileformat describes simple mesh geometry through the .dat files and (sub)assemblies are typically built out of .dat load commands in .ldr files. Full models are typically expressed in .mpd files.
With the way I have set the importer up the goal is to eventually have a library of 3dm files for high quality parts and swap those out for the original mesh-based parts.
Will be fun to add that when I get to do the export side of this
The .io files look to be password locked zip-files, so importing those directly is not going to be an option. But you can export from Studio to .mpd or .ldr and load that subsequently in Rhino. Here the Cougar example model that comes with Studio (blue disk added by me).
I have to issue a correction - the design software that is no longer supported was called LEGO Digital Designer (LDD). It used the LDraw file format.
Yeah, a lot of older models can be found online but not so much with any of the newer ones. There is also an issue with support for the parts library since new parts are constantly appearing and only the Studio library is regularly updated.
This nice thing about Studio is that it is integrated with Bricklink (a marketplace for LEGO parts, among other things) so you can get real time market prices for any MOC you create (plus warnings about parts that may not be available in certain colors) and then buy the pieces from a network of worldwide 3rd party sellers.
If you’re interested in the Studio render capabilities, this was a blog post on how to customize settings, but otherwise the interface is very black box.