Code Monkey home page Code Monkey logo

importldraw's Introduction

Import LDraw

A Blender™ plug-in for importing LDraw™ file format models and parts.

Tower Bridge

Purpose

Import LDraw imports LEGO® models into Blender.

It supports .mpd, .ldr, .l3b, and .dat file formats.

It's intended to be accurate, compatible, and fast (in that order of priority).

Features

  • Works with Blender 2.81 up to at least Blender 4
  • Mac, Windows and Linux supported.
  • Bricksmith compatible.
  • MPD file compatible.
  • LeoCAD groups and cameras (both perspective and orthographic) supported.
  • LSynth bendable parts supported (synthesized models).
  • Cycles and Blender Render engines supported. It renders either engine from a single scene.
  • Import photorealistic look, or Instructions look.
  • Physically Based Realistic materials - standard brick material, transparent, rubber, chrome, metal, pearlescent, glow-in-the-dark, glitter and speckle.
  • Principled Shader supported Uses Blender's 'Principled Shader' where available for optimal look (but still works well when unavailable).
  • Accurate colour handling. Correct colour space management is used so that e.g. black parts look black.
  • Direct colours supported.
  • Back face culling - fully parses all BFC information, for accurate normals.
  • Linked duplicates - Parts of the same type and colour can share the same mesh.
  • Linked studs - studs can also share the same mesh.
  • Studs can include the LEGO logo on them, adding extra geometry.
  • Gaps between bricks - Optionally adds a small space between each brick, as in real life.
  • Smart face smoothing - Uses Edge-Split Modifier and Sharp Edges derived from Ldraw lines, for smooth curved surfaces and sharp corners.
  • Concave walls - Optionally look as if each brick has very slightly concave walls (with the photorealistic renderer), which affects the look of light reflections.
  • Light bricks - Bricks that emit light are supported.
  • Parenting Minifigs - Optionally make the parts of a minifig parented to each other, so e.g. rotating an arm also moves the hand with it.
  • Fast - even large models can be imported in seconds.

Ghostbusters

Installation and usage

Installing the add-in

  • Download the latest version from the Releases page
  • Open Blender
  • If you are in Blender 2.79 or lower, choose from the menu: File > User Preferences
  • If you are in Blender 2.81 or later, choose from the menu: Edit > Preferences
  • Click the Add-ons tab
  • Click the Install from file... button (Blender 2.79) or Install... button (Blender 2.81+)
  • Navigate to the zip file you downloaded and select it
  • Find Import LDraw in the list of Add-ons (search for LDraw if necessary)
  • Tick the check mark next to it to activate the add-on.
  • Click the Save User Settings button (Blender 2.79) or Save Preferences button (Blender 2.81+) so that it will still be active next time you launch Blender.

Setting the LDraw Parts Library directory

  • Download the latest complete LDraw Parts Library and unzip it to a directory e.g. called 'ldraw'.
  • (Note there currently seems to be an issue if the path to the ldraw directory contains spaces, so avoid using spaces in the full path to the ldraw directory.).
  • OPTIONAL: Download the unofficial parts and unzip it to sub-directory 'ldraw/unofficial/'
  • From the Blender menu click: File > Import > LDraw (.mpd/.ldr/.l3b/.dat).
  • In the bottom left of Blender's window, there's a panel of Import Options.
  • The first option is the LDraw Parts Library directory. Type the full filepath to the 'ldraw' directory you unzipped to.
  • To save that directory and try it out, choose a file to import.

Tugboat

History

This plug-in is by Toby Nelson ([email protected]) and was initially written in May 2016.

It was inspired by and initially based on code from LDR-Importer but has since been completely rewritten.

Marina Bay Sands

License

Import LDraw is licensed under the GPLv2 or any later version.

Thanks

Thanks to BertVanRaemdonck for the 'concave walls' feature, and for the useful feedback and suggestions.

External References

Blender logo

Blender™ is the free and open source 3D creation suite.

LDraw logo

LDraw™ is an open standard for LEGO CAD programs that allow the user to create virtual LEGO models and scenes. You can use it to document models you have physically built, create building instructions just like LEGO, render 3D photo realistic images of your virtual models and even make animations. The possibilities are endless. Unlike real LEGO bricks where you are limited by the number of parts and colors, in LDraw nothing is impossible.

LDraw™ is a trademark owned and licensed by the Estate of James Jessiman. This plug-in is not developed or endorsed by the creators of The LDraw System of Tools.

Bricksmith logo

Bricksmith allows you to create virtual instructions for your Lego creations on your Mac.

LSynth example

LSynth is a program that synthesizes bendable parts for LDraw files.

LEGO logo

LEGO® is a registered trademark of the Lego Group

importldraw's People

Contributors

acui avatar ali1234 avatar bertvanraemdonck avatar bskaggs avatar cuddlyogre avatar tobylobster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

importldraw's Issues

Set default color for import?

I can't figure out how to import bricks with any color other than red set to the "current color" - is there a UI element I'm missing somewhere?

ImportLDaw logo

Hello,

I will add Blender integration to LPub3D shortly and would like to use ImportLDaw.

An ImportLDaw logo, so I can properly reference this package would be much appreciated.

Cheers,

Batch rendering with different colors

Hello!

I am currently trying to batch render a large amount of individual pieces in the various colors that they come in. I am not very experienced in blender so maybe I am missing something obvious. I am having issues with figuring out how to import the pieces in colors other than the default red. Has anyone else had any success with this?

Thank you!

horizon_color takes 3 arguments, not 4

Line 3271 (or close) reads:

scene.world.horizon_color = (1.0, 1.0, 1.0, 1.0)

This should read:

scene.world.horizon_color = (1.0, 1.0, 1.0)

Otherwise, an error is thrown by Blender and the horizon is black.

Import fails - Blender 3.4 removed use_customdata_edge_bevel mesh property

Hi,
can you please update plugin to work with Blender 3.4 and newer? Blender recently removed use_customdata_edge_bevel
Here is more information about Python breaking changes in 3.4:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.4/Python_API

Python: Traceback (most recent call last):
File "C:\Users\shugo\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\io_scene_importldraw\importldraw.py", line 391, in execute
loadldraw.loadFromFile(self, self.filepath)
File "C:\Users\shugo\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\io_scene_importldraw\loadldraw\loadldraw.py", line 4300, in loadFromFile
rootOb = createBlenderObjectsFromNode(node, node.matrix, name)
File "C:\Users\shugo\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\io_scene_importldraw\loadldraw\loadldraw.py", line 3579, in createBlenderObjectsFromNode
ob.data.use_customdata_edge_bevel = True
AttributeError: 'Mesh' object has no attribute 'use_customdata_edge_bevel'
bpy.ops.import_scene.importldraw(filepath="D:\io\Wietse Bricks\WBCorvetteMOC - Copy.ldr", ldrawPath="D:\Blender Versions\ldraw3\", bevelEdges=True)

Mesh to Geometry

Is it possible to import Geometry instead of Meshes?

In LDView it is possible to export to .3ds which can be opened and edited in Blender. (The problem with LDView export is that it gives our very low poly models). But since with your addon you only convert to meshes similar to an .stl file this makes editing the brick geometry afterwards pretty much impossible.

Your script puts out very nice bricks, better than anything else, so it would really be a shame if this wasn't possible.

Automatic parenting of related parts

This is another tricky request :-)

When importing a minifig, it would be nice if we could parent the hands to the arms, the arms to the torso, etc.; similarly, when importing a car, ideally we'd like the wheels to be parented to the piece holding them. Windows could be parented to window frames, and so on.

My idea is to have a list of relationships:

auto_parents = [
    ('3842', [('3626', 0, 0, 0)]), # parent helm to head
    ...
]

where the first item of the tuple is the child, and the second one is a list of possible parents; for each parent, we have the name of the parent piece and the x, y, z coordinates where we expect it to be found, relative to the child item.
Then the importer would look at all imported parts, and for each of them check if they are part of this list; if they are, it would go through the list of possible parents, and create a child-parent relationship to each parent found in the expected position.

If you think this could work, and if you can give me some hint on where in the code this algorithm could reside, I can try to find some time to implement it.

Missing textures on minifig torsos exported out of Studio.

Some official parts - for instance 973p13 don't seem to carry over texture information into Blender.
https://www.ldraw.org/parts/official-part-lookup.html?folder=parts&partid=973p13

Other parts that have been custom made by BrickLink also can be affected, such as 973pb1161 - which is an unofficial part, so you sort of expect that to get a bit wonky.

Is there a way to import parts with textures that aren't vertex based? I know one workaround is to just apply the texture with UV mapping, but it would be nice to not have to do that for complex scenes.

This post seems to allude to a method.
https://www.eurobricks.com/forum/index.php?/forums/topic/175033-converting-parts-with-textures-from-studio-to-ldraw/

Gaps between freestyle lines in Lego instructions look.

[Hello.]

First of all thanks for your great job and very useful addon.
I have an issue with freestyle lines, when i trying to make lego instructions look render. There are gaps in those lines which lay on plane where the stud's cylinder connects with brick plane. And this line looks dashed with random gaps. Maybe there is a way to fix this issue? Or i do something wrong?
brick

I could not import the submodels in a model

When importing a file containing submodels (other LDraw files within the file) it does not find them. I took a look in the code and I believe you do not search for the parts within the directory, where the file is located.

scratches

Hi! how do i add scratches? I'm not a pro in blender. can someone tell me how i shall fix that??

Error Importing in Blender 2.X, LDraw Part Library not found

Hi,
I installed the plugin on multiple Blender versions (2.79, 2.8,2.81,2.83,2.93)
but in all of them I get same error:
"Could not find LDraw Part Library"

I installed the plugin 1.9 and also 1.11, also Ldraw complete zip on windows10
What is it missing?
thank you

All appropriate stud designs should have the LEGO logo on them (if the option is chosen).

Stud Research

Many of the official stud*.dat files should not have an associated logo. Either they are used on the underside of a part (which don't have a logo), or they are hollow and you can see right through to the other side, or they just don't have the logo in real life. By my count, that leaves 10 stud files that should have the logo, see table below.

Duplo parts use either 'DUPLO' or 'LEGO' logo, depending on when they were made, and perhaps geographically where they are sold. http://bricks.stackexchange.com/questions/6115/what-logos-appear-on-duplo-brick-studs . Quatro parts (double the size of Duplo) don't sport a logo AFAIK.

Don't forget the low-res versions of these files too.

file Should it have a logo? Example part using stud Notes
stud.dat YES 3001 Done
stud2.dat YES 2719 Done
stud2a.dat No 643
stud3.dat No 2046
stud3a.dat No 2449
stud4.dat No 643
stud4a.dat No 208
stud4f*.dat No 92099
stud4h.dat No 18975
stud4o.dat No 2343
stud4od.dat No 2681
stud5.dat No 33177 references stud.dat inside
stud6.dat YES 2655
stud6a.dat YES 2654
stud7.dat YES 3011 Duplo
stud8.dat No 3011 Duplo underside
stud8a.dat No 3664
stud9.dat No 30179
stud10.dat YES 3941
stud11.dat No 31465 Duplo
stud12.dat No u8100 Underside
stud13.dat YES 4773a
stud14.dat No 49465 Quatro
stud15.dat YES 92947
stud16.dat No 10048
stud17a.dat No 6032
stud18a.dat No 11213
stud20.dat YES 2296 Duplo
stud21a.dat No 47715
stud22a.dat No 47715
stud23a.dat No - Not used?
stud25.dat No 48411 Quatro
studa.dat YES 429
studel.dat No 2683 Electrical contacts - no logo
studline.dat No - Not used?
studp01.dat No 809
studx.dat No 32531

4774cu

After using instruction render and reimporting as realistic, it still uses instruction style renderer

Hi Toby! This plugin is an extremely impressive feat - I'm playing around with it and got a huge smile on my face!

A small issue I found is the following:

  1. Create a new file and import an ldraw-model as realistic
  2. It renders as expected (realistically)
  3. In the same file, delete your model and import a new one, as instruction image
  4. Render - it does so as expected (cartoonishly)
  5. Now do step 1-2 again. It does not render as expected. (I expect realistic, but get cartoony.)

I'm relatively new to Blender, but it seems like some render settings aren't set properly upon import. Is there a way for me to fix this? It's relatively simple for me to work around once you know about it, so it's not a big deal - just thought it might help make an awesome plugin even better.

Thanks for the amazing work!

KeyError when importing model with System/International Fonts (Spanish) activated

Hi, I found this error making a tutorial about your add-on for Spanish users. Using Blender default language (International Fonts unchecked in System preferences) works OK, there is only a warning due to a custom colour from an old version of MLCad (this is not the problem). In this case the console shows:

10:24:31.81 [importldraw] The LDraw Parts Library path to be used is: c:\temp\p\
tnt\LDraw
10:24:31.81 [importldraw] Use LSynth Parts requested
10:24:31.81 [importldraw] Standard-res primitives selected
10:24:31.81 [importldraw] Loading files
10:24:32.75 [importldraw] Creating NodeGroups
10:24:32.75 [importldraw] Creating Blender objects
10:24:33.46 [importldraw] WARNING: WARNING: Could not decode 50331648 to a colou
r
10:24:34.70 [importldraw] Number of vertices: 259278
10:24:35.02 [importldraw] Number of vertices of convex hull: 231
10:24:35.02 [importldraw] Centre object
10:24:35.02 [importldraw] Adding 147 objects to scene
10:24:35.02 [importldraw] Load Done

But when International Fonts is checked and Spanish is selected, the import does not work:

10:21:58.74 [importldraw] The LDraw Parts Library path to be used is: c:\temp\p\
tnt\LDraw
10:21:58.74 [importldraw] Use LSynth Parts requested
10:21:58.74 [importldraw] Standard-res primitives selected
10:21:58.74 [importldraw] Loading files
10:22:00.13 [importldraw] Creating NodeGroups
10:22:00.13 [importldraw] createBlenderDistanceToCenterNodeGroup #create
10:22:00.13 [importldraw] createBlenderVectorElementPowerNodeGroup #create
10:22:00.13 [importldraw] createBlenderConvertToNormalsNodeGroup #create
10:22:00.13 [importldraw] createBlenderConcaveWallsNodeGroup #create
10:22:00.13 [importldraw] createBlenderSlopeTextureNodeGroup #create
10:22:00.13 [importldraw] createBlenderFresnelNodeGroup #create
10:22:00.13 [importldraw] createBlenderReflectionNodeGroup #create
10:22:00.13 [importldraw] createBlenderDielectricNodeGroup #create
10:22:00.13 [importldraw] createBlenderLegoStandardNodeGroup #create
10:22:00.13 [importldraw] createBlenderLegoTransparentNodeGroup #create
10:22:00.14 [importldraw] createBlenderLegoTransparentFluorescentNodeGroup #crea
te
10:22:00.14 [importldraw] createBlenderLegoRubberNodeGroup #create
10:22:00.14 [importldraw] createBlenderLegoRubberTranslucentNodeGroup #create
10:22:00.14 [importldraw] createBlenderLegoEmissionNodeGroup #create
10:22:00.14 [importldraw] createBlenderLegoChromeNodeGroup #create
10:22:00.14 [importldraw] createBlenderLegoPearlescentNodeGroup #create
10:22:00.14 [importldraw] createBlenderLegoMetalNodeGroup #create
10:22:00.14 [importldraw] createBlenderLegoGlitterNodeGroup #create
10:22:00.14 [importldraw] createBlenderLegoSpeckleNodeGroup #create
10:22:00.14 [importldraw] createBlenderLegoMilkyWhiteNodeGroup #create
10:22:00.14 [importldraw] Creating Blender objects
Traceback (most recent call last):
  File "C:\Users\josealfonso.LABVIRTUAL\AppData\Roaming\Blender Foundation\Blend
er\2.79\scripts\addons\io_scene_importldraw\importldraw.py", line 385, in execut
e
    loadldraw.loadFromFile(self, self.filepath)
  File "C:\Users\josealfonso.LABVIRTUAL\AppData\Roaming\Blender Foundation\Blend
er\2.79\scripts\addons\io_scene_importldraw\loadldraw\loadldraw.py", line 3954,
in loadFromFile
    rootOb = createBlenderObjectsFromNode(node, node.matrix, name)
  File "C:\Users\josealfonso.LABVIRTUAL\AppData\Roaming\Blender Foundation\Blend
er\2.79\scripts\addons\io_scene_importldraw\loadldraw\loadldraw.py", line 3446,
in createBlenderObjectsFromNode
    createBlenderObjectsFromNode(childNode, childNode.matrix, childNode.filename
, childColourName, blenderParentTransform, localToWorldSpaceMatrix * localMatrix
, blenderNodeParent)
  File "C:\Users\josealfonso.LABVIRTUAL\AppData\Roaming\Blender Foundation\Blend
er\2.79\scripts\addons\io_scene_importldraw\loadldraw\loadldraw.py", line 3311,
in createBlenderObjectsFromNode
    mesh, newMeshCreated = createMesh(name, meshName, geometry)
  File "C:\Users\josealfonso.LABVIRTUAL\AppData\Roaming\Blender Foundation\Blend
er\2.79\scripts\addons\io_scene_importldraw\loadldraw\loadldraw.py", line 3220,
in createMesh
    material = BlenderMaterials.getMaterial(faceColour, isSlopeMaterial)
  File "C:\Users\josealfonso.LABVIRTUAL\AppData\Roaming\Blender Foundation\Blend
er\2.79\scripts\addons\io_scene_importldraw\loadldraw\loadldraw.py", line 2164,
in getMaterial
    material = BlenderMaterials.__createNodeBasedMaterial(blenderName, col, isSl
opeMaterial)
  File "C:\Users\josealfonso.LABVIRTUAL\AppData\Roaming\Blender Foundation\Blend
er\2.79\scripts\addons\io_scene_importldraw\loadldraw\loadldraw.py", line 1725,
in __createNodeBasedMaterial
    BlenderMaterials.__createCyclesConcaveWalls(nodes, links, 0.2)
  File "C:\Users\josealfonso.LABVIRTUAL\AppData\Roaming\Blender Foundation\Blend
er\2.79\scripts\addons\io_scene_importldraw\loadldraw\loadldraw.py", line 2023,
in __createCyclesConcaveWalls
    out = nodes['Group']
KeyError: 'bpy_prop_collection[key]: key "Group" not found'

location: <unknown location>:-1

location: <unknown location>:-1

Trans-black (LDRAW color 40) not rendered as transparent

I looked through the script and see how you're determining transparency if raw hex values are provided, but how do you make the determination if it's a "standard" LDRAW color? All the other transparent parts I've rendered look fine. Is there a lookup table somewhere?

First impressions

You blew me away, Toby! I was planning to spend my summer on improving the LDRImporter, and now you show up with something way better than I could ever hope to achieve. Your importer tackles mpd models perfectly, does a great job with normals, has no problem with generated parts and attains an insane speed (my 5111 piece WIP Big Ben in about 30 seconds!). Furthermore, the code looks very transparent at first sight. It's great that we could be an inspiration to you, and it joys me to see little pieces of our own code return here. So awesome job!

That being said, here are some remarks I have after a first tryout:

  • I think the default scale is quite big. When I tried to change the scale, nothing changed, however. Changing other values like the gap size did have an effect though, and I can spot nothing in the code that fixes the scale on a certain value...
  • I see you have a fresnel node for the transparent materials, but not for the rest. Why not? The Fresnel effect is something present in every material. The roughness of the diffuse might be a little bit higher for my taste too.
  • When importing certain pieces, like the minifig binoculars, I get the warning that the program found double sided polygons. From what I understand from the code, this is something that lies with the parts themselves, and is nothing that the importer can fix. However, the result is something that is really messy to fix in Blender. Are you sure there is nothing you can do to make the part as good as possible? You could guess a normal and apply that consistently, so that it wouldn't be too much work to adjust everything manually in Blender.

Furthermore, your program looks really complete, but there are still some goals worth striving for:

  • Don't do the logo's with geometry, but with a normal map. This requires UV-unwrapping of the studs though, something I've been told is quite tricky.
  • Display mold marks on the bricks in logical places. This can be done with normal maps, or perhaps with geometry. I have a .dat file of such a logo with mold mark lying around by the way.
  • Render slopes with the grainy texture (a voronoi texture works beautifully for this, see my custom LDRImporter branch). As far as I know, though, there is no way to automatically decide which faces should get this texture, so it would require a hard coded list, which means quite a bit of work.
  • Don't use an edge split modifier with an angle limit. Parts like 2489 get smooth edges due to this, even where they shouldn't. A solution could be to interpret the "2" lines from the .dat files, and use them to determine which edges should be sharp and which ones smooth.
  • Implement bevels with a bevel shader. There is one available online, but this uses osl, which requires you to render with cpu. I'm looking myself into a way of building a custom node that blurs normal maps, but I'm still in the research stage.
  • Give the option to remove unnecessary geometry. You might be able to detect cases in which a stud is covered by a brick, or the underside of a brick is obscured. This might lighten the load of the computer, but with how fast your importer is, that isn't much of a problem!

That's everything I can think about after an exhilarating first test. Keep up the good work!

Error when trying to import ldr

When i try to import a ldr model in blender 2.81, it throws me an error :

`Traceback (most recent call last):
File "/home/uncle/.config/blender/2.81/scripts/addons/io_scene_importldraw/importldraw.py", line 391, in execute
loadldraw.loadFromFile(self, self.filepath)
File "/home/uncle/.config/blender/2.81/scripts/addons/io_scene_importldraw/loadldraw/loadldraw.py", line 4297, in loadFromFile
BlenderMaterials.createBlenderNodeGroups()
File "/home/uncle/.config/blender/2.81/scripts/addons/io_scene_importldraw/loadldraw/loadldraw.py", line 3140, in createBlenderNodeGroups
BlenderMaterials.__createBlenderSlopeTextureNodeGroup()
File "/home/uncle/.config/blender/2.81/scripts/addons/io_scene_importldraw/loadldraw/loadldraw.py", line 2490, in __createBlenderSlopeTextureNodeGroup
node_voronoi = BlenderMaterials.__nodeVoronoi(group.nodes, 3.0/Options.scale, -100, 155, 'INTENSITY')
File "/home/uncle/.config/blender/2.81/scripts/addons/io_scene_importldraw/loadldraw/loadldraw.py", line 2108, in __nodeVoronoi
node.coloring = colouring
AttributeError: 'ShaderNodeTexVoronoi' object has no attribute 'coloring'

location: :-1

`

I've looked at the new blender API, but I couldn't find the change even in the release note. They just have remove the coloring attribute.

Some lines aren't applied to mesh edges

The problem happens because the code tests every triangle and quad edge against the lines in the model. But for some models this fails because two triangles may be used with a single line. For example the space minifig body:

screenshot_2018-11-10_16-36-51

Here the bevel weight (blue lines) has not been set on the edge nearest the camera. On the front of the body this edge is made of two quads. On the side it is many quads. But in the ldraw file the line is defined as a single segment. Therefore no single quad edge has the same vertices as the line segment, and bevel/sharp is never applied.

Blender warns about UI strings ending in '.'

When launched from the console with ImportLDraw installed, Blender outputs the following:

RNA_def_property_ui_text: 'Sets a scale for the model.' description from 'importScale' '' ends with a '.' !
RNA_def_property_ui_text: 'Each object has a five digit prefix eg. 00001_car. This keeps the list in it's proper order.' description from 'numberNodes' '' ends with a '.' !
RNA_def_property_ui_text: 'The object is centred at the origin, and on the ground plane.' description from 'positionOnGround' '' ends with a '.' !
RNA_def_property_ui_text: 'Shows the LEGO logo on each stud (at the expense of some extra geometry and import time).' description from 'useLogoStuds' '' ends with a '.' !
RNA_def_property_ui_text: 'Creates a Blender Object for each and every stud (WARNING: can be slow to import and edit in Blender if there are lots of studs).' description from 'instanceStuds' '' ends with a '.' !
RNA_def_property_ui_text: 'Some older LDraw parts have faces with ambiguous normals, this specifies what do do with them.' description from 'resolveNormals' '' ends with a '.' !
RNA_def_property_ui_text: 'Adds a Bevel modifier for rounding off sharp edges.' description from 'bevelEdges' '' ends with a '.' !
RNA_def_property_ui_text: 'Adds a ground plane and environment texture (for realistic look only).' description from 'addEnvironment' '' ends with a '.' !
RNA_def_property_ui_text: 'Position the camera to show the whole model.' description from 'positionCamera' '' ends with a '.' !
RNA_def_property_ui_text: 'When positioning the camera, include a (percentage) border around the model in the render.' description from 'cameraBorderPercentage' '' ends with a '.' !

I assume this is saying that UI descriptions should not end with a '.'

For example, one such string:

description="Sets a scale for the model.",

Support integration with stud.io

Hi! I've been using bricklink's stud.io editor and PartDesigner a lot and recently found this tool as I'm looking into using blender for rendering (Mostly as my gpu isn't properly supported).

How possible would it be to support stud.io?

Models

stud.io saves models as .io files which are apparently similar to .ldrs. stud.io does allow models to be exported to .ldr which works for this tool. However it does feel like a clunky workflow if you're trying to get something just right. I would propose in supporting .ios for importing. They could possibly just be implicitly converted to .ldr when imported?

LDraw parts

stud.io uses its own ldraw folder located in its install location. This could be added to the default locations?

Custom parts

One of the great things about stud.io is that it has a part designer which allows creating custom parts. I mainly use this for adding stickers to parts that aren't yet supported. PartDesigner saves these custom parts as .part files. When exported to stud.io they are saved as .dats in %AppData%/Local/Stud.io (for windows anyway) with a similar folder structure to ldraw. Looking through some of the code it looks possible to import them in a similar way to unofficial parts.

- Jack

StudVersion 4 missing vertices

First of all: awesome tool, mate!
I was waiting for something like this for years.
Finally, there is an easy way to use ldraw models in modern 3d packages.
Thank you so much! :)

But there seems to be an issue with StudVersion 4. See image below.
I changed the script to test 3 and 5, which seems to work fine. But, version 4 seems to be the best choice if one wants to render high-quality close-ups
Any ideas?
I don't know much about blender. It's a fresh 2.77 install.

legoblender

Holes in lego text when bricks imported with high resolution

it is very hard to see in object mode because everything is the same color, but if you change it so the text is a different color then the brick you see that it has holes in it. This is only the case for hi-res thought with standard and low res it does not have holes.
Screen Shot 2019-06-27 at 12 03 36 AM

Colour import issue

I installed it correctly but when importing models, all materials end up as being a Lego Standard yellow, parts that had the same colour (ie two black parts for example) did share the same material but all were the standard yellow. I attempted to change my import settings and new Ldraw models but none of that worked.

A friend who correctly installed it tried to assist and sent me his version but the same issue occured. (I don't use Github a lot so I may be pointing out something obvious I've missed or that it's an issue with my Blender rather than the plugin but I don't know enough to find a fix).

Importing of grouped pieces

Hi there, and thanks for this wonderful add-on!

I'm rather new to both blender and leocad, so I'm not even sure whether this request makes much sense. If it doesn't, just please tell me :-)

In leocad you can group pieces by selecting them and pressing Ctrl+G. This can be used to group together a wheel with its tire, or a minifig's arm with the corresponding hand. As far as I can tell, these still get imported as two totally separate pieces in blender.

Would it be possible to import them by preserving the group? I'm new to blender, so I'm not even sure what would be the correct form of importing them: whether a parent-object relationship, or a constraint, or something else.

Feature Request: Option to import .dat without studs to .obj

I wanted to start off by saying I'm very impressed with this module! Very robust code, nice work!

I need to export LDRAW .dat files into .obj for use with a Unity Game Engine application. In addition, I am using physics simulation as part of my project and will require realistic snapping of blocks. The best method for this has proven out to be creating a separate .obj of the block WITHOUT studs. This allows snapping the studs inside of the ports of lego blocks.

This module seems like the perfect tech enabler for this feature.

What:

  • Export .dat file with studs .obj - (As object file)
  • Export .dat without studs -c.obj - (As collision file)

Why:

  • .dat file not interpreted by game engine. .obj filetype needed.
  • Collision file needed for game engine use. Accurate snapping of Lego blocks.

hasCollections is always false

I'm on revision 82e6764 and blender-2.80.0-git.ebc44aae9897-windows64.

hasCollections is set on line 236 but is always false.
hasCollections = hasattr(bpy.data, "collections")

This causes the error with setupInstructionsLook

    if bpy.data.groups.find('Black Edged Bricks Collection') < 0:
AttributeError: 'BlendData' object has no attribute 'groups'

When checking in the Python console, that function returns true and when calling the function where hasCollections is used, it also returns true.

To troubleshoot this, I used this piece of code where hasCollections is defined.

for obj in bpy.data.objects:
    print(obj.name)

This is the error returned when Blender is started:

    for obj in bpy.data.objects:
AttributeError: '_RestrictData' object has no attribute 'objects'

The cause is described at https://blenderartists.org/t/attributeerror-restrictdata-object-has-no-attribute-filepath/607717 but I was unable to come up with a solution that would work with ImportLDraw.

Export to LDraw

Is possible to export from blender to a new piece of LDraw or modify anyone in the future?

The models are not imported correctly

I downloaded importldraw1.1.11_for_blender_281.zip and make blender have the functionality of importing .dat files. But I also found that some models were not imported correctly. For example, what the model 12.dat actually is is different from what it is after imported into blender, so are 3020.dat and 16.dat(sorry i just couldn't upload images, so please see here: https://weibo.com/akahs?from=feed&loc=avatar&is_all=1)

I use Blender2.81a released on 05-Dec-2019 11:51. OS is win10. I installed the plugin according the instruction in README.md, so I think this is a bug rather than my mistake operation. Can anyone help me fix this bug and import model correctly? Thanks!

Request for lighted parts

Would it be possible to add (optional/toggle) support for lighted bricks, specifically 98785:

https://brickset.com/parts/design-98785

(ideally in LDRAW color 36)

My old POV-Ray Radiosity scripts supported this, and it's amazing how much difference the subtle effect can make, particularly with (deliberately) darker lighting/environments.

If you consider the request, please continue your focus on realism - not looking for this to turn out to be some sort of high-intensity headlight, ideally it should be presented as accurately to life as possible.

Case sensitive settigs (LeoCAD output)

When try import .ldr/.mpd files, created and saved using LeoCAD, ImportLDraw can'd do it.

It's look like LeoCAD output issue

But, it would be cool if add setting checkbox to ImportLDraw's file chooser dialog:

  • Case sensitive import

If it will be unchecked then ImportLDraw should ignore case sizes of models & parts names inside imported files.

Installation Issue

2019-11-08

Hi, I get this error when I try to activate the addon after installation. Don't know if I'm being stupid but any help is appreciated.

Thanks

Imported models easily explode when physics are active

Hi!
Thanks for this importer, it's fantastic! :-) I'm having a little problem with the imported models though, and it might be that it's not actually something caused by ImportLDraw but rather Blender itself (or even on some mistakes of mine): if you select some connected pieces and then make them "active" from the physics tab, they'll "explode" once you run the animation.
My setup:

  • scale when importing: 0.1
  • the rigid body collision shape is set to "mesh"
  • the sensitivity margin is set to 0 (I tried using a negative value, but Blender does not allow that)

Connecting the pieces with the "Connect" button in the physics tab helps only partially, because anyway it allows the pieces do compenetrate each other while running a physic simulation. But anyway this should not be needed, as the shape of the pieces itself should keep the model united.

I've had a look at the code, and it seems to me that the gaps are created by downscaling the pieces a bit. That's probably why increasing the gap doesn't help in this case: while indeed the studs get smaller, also the connecting piece gets smaller, so there might be no margin between them.

So, the question: would it make sense to add an option to downscale only the studs, the technical axles and a few other parts? In an ideal would the importer could detect the collisions itself and automatically decide which model parts need to be downscaled, but I guess that's far from trivial (unless Blender itself provides some function to find the collision area).

pink colouring to scene when rendering

LDraw models import correctly but all renders have a pink colouring to them, as though the light were pink, even when the light and the included LDraw ground place are deleted; see attached render.
5580
Affects Cycles and Eevee engines, but not Workbench, in both CUDA and CPU modes.
Also affects "render preview" viewport shading in Layout mode.

Using Blender 2.81 and the latest master of ImportLDraw.

Many thanks in advance for any advice/fixes.

3678* should not have a textured slope

Title is the explanation - set 926 (Classic Space/Command Center) has 3678 in transparent that shouldn't be textured (and to the best of my knowledge, 3678 isn't texted in any set)

EDIT: Come to think of it, isn't it a general rule that no vertical slope in excess of 45 degrees is textured?

Logos in Open Studs too large

Hi Toby, just discovered your addon yesterday, and I have to say it is incredible! Excellent work in expanding, building upon, and re-writing an already great system. I am very impressed, and really like your implementation of the bevel modifier.

It's too bad that many High Res Primitives in LDraw often are modeled with disconnected vertices or have an uneven fill carried over from the Standard Res Primitives (check out the ends of Technic pin 6558 to see what I mean). This of course is because the parts were probably never intended to be used with fancy things like bevel modifiers which grab these loose vertices and can cause all kinds of distortion. Not sure that there's really anything the add-on could do to fix that though... :-)

6558 dat

One thing I've come across that probably could be fixed is that logos inside open studs unfortunately come out too large (they are the same size as on closed studs, which causes the logo to be cut off). I've found that one has to manually select these logos and shrink them by 0.76 to keep them within the diameter of the open stud. You can see this in parts like 3794b or 18975.

Anyway, thank you again so much for your excellent work in developing this extremely helpful addon!

-Adam

99781 dat

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.