M2m

Blender - LDD Plugin

Recommended Posts

I finished a Proof-of-Concept.

That means a couple of things are working. But quite allot of things still to-do: LDD and Blender have different axis, Flex parts are floating around, correct grouping of subparts (g, g1, g2, .... files), materials, textures, testing on macOS

Anyway this is the state so far:

Blender_Proof_of_Concept.jpg

Share this post


Link to post
Share on other sites
  • Aligning LDD and Blenders different axis: ✔️
  • Address Flex parts floating around: ✔️
  • Preliminary Testing on Windows 10 & maxOS 10.13 ✔️
  • grouping of parts and subparts (g, g1, g2, .... files)  ✔️
  • brick seams (preliminary) ✔️
  • Logo-on-bricks ✔️
  • Hosting on public repository  ✔️

Pending:

  • grouping of parts and subparts (g, g1, g2, .... files)
  • correct normals
  • materials
  • textures
  • brick seams
  • Logo-on-bricks
  • testing on different OSes (macOS, Linux)
  • Hosting on public repository :wink:

 

Blender_Proof_of_Concept02.jpg

Edited by M2m

Share this post


Link to post
Share on other sites

OK I opened the Repo now for public: 

sttng/ImportLDD: A Blender plug-in for importing LEGO Digital Designer file format (lxf, lxfml) LEGO models. (github.com)

Bear in mind this is basically still very, very unpolished and dirty code. I will still continue to commit code randomly. This also means that currently I can't give too much helpful tips and support - if any at all.

importldd.py is the file you need, and to "install" via Prefernces -> Add-ons. Or you can run the code via the Scripting Tab / Workspace.

Still missing features:

  • reading of normals from .g files (even so Blender seems to do a very good Normal calculation by itselft)
  • materials
  • textures
  • testing on different OSes (Linux)

Anyway feel free to try it, clone it or come up with suggestions or wishes. 

Blender_Proof_of_Concept03.jpg

Edited by M2m

Share this post


Link to post
Share on other sites

Yeah. The LDraw Plugin for Blender is great. But it can't handle (so far) the new LDD Mod Parts, unless there are LDraw Parts Ports of them.

My Plugin reads the Geometry directly from the .g files, so it can handle every LDD Parts (including mod parts.) But it is lacking nice materials (that's where the LDraw Plugin really shines) and of course many other features. On the other hand the LDraw Plugin existed for years, and this one only since a week :wink:

Edited by M2m

Share this post


Link to post
Share on other sites
On 12/5/2020 at 2:54 PM, M2m said:

Yeah. The LDraw Plugin for Blender is great. But it can't handle (so far) the new LDD Mod Parts, unless there are LDraw Parts Ports of them.

My Plugin reads the Geometry directly from the .g files, so it can handle every LDD Parts (including mod parts.) But it is lacking nice materials (that's where the LDraw Plugin really shines) and of course many other features. On the other hand the LDraw Plugin existed for years, and this one only since a week :wink:

If you creat  the LDD-Mod-Parts model into a .DAT file,then copy it to the Plugin's   LDraw Parts Library

booooom,now you can import the new model to the BLENDER

also,you can from stu.dio's new part copy the .dat file to the same file address,then it will work when you export a .ldr file from stu.dio with some mod part

Share this post


Link to post
Share on other sites

I don't think all the new LDD-Mod parts are available in either Ldraw or Stud.io. And as you say you have to create a dat part of the mod-file. If you have done that already, I think you should share with the community. There seems people are questioning on how to do it in the thread about new Unity Lego parts. Maybe you can give some helpful input there :)

Share this post


Link to post
Share on other sites
21 hours ago, M2m said:

I don't think all the new LDD-Mod parts are available in either Ldraw or Stud.io. And as you say you have to create a dat part of the mod-file. If you have done that already, I think you should share with the community. There seems people are questioning on how to do it in the thread about new Unity Lego parts. Maybe you can give some helpful input there :)

For example,you can use the Part Designer,click the "Import",selcet the "STUDIO PART",then selcet and export a "new" part(It's same of the stu.dio part,if it only exists in the stu.dio part library)

but in this way to make a new .dat part,it is not  simple and elegant as a part from ldraw part library

 

Share this post


Link to post
Share on other sites
2 hours ago, Jason C. Hand said:

How do you install this onto Blender?

Also on Windows you can go to Edit -> Prefernces -> Add-ons and choose the install button. Then browse and select importldd.py. Then you have to activate it with the checkbox in front of it.

It's my 1st ever Blender plugin. Anyway you can also run it by going to the "Scripts" Workspace and load / run importldd.py.

Then you will be present with an import dialogue. It should auto-detect your db.lif (or extracted db folder) - you can see at the upper right.

Let me know your success rate :wink: or of course any potential errors.

As I'm a little occupied with work recently I unfortunately didn't have time to focus on this as much as I would like. For example lack of importing of decals info is what is bugging myself.

Cheers !

 

Edited by M2m

Share this post


Link to post
Share on other sites
49 minutes ago, M2m said:

Also on Windows you can go to Edit -> Prefernces -> Add-ons and choose the install button. Then browse and select importldd.py. Then you have to activate it with the checkbox in front of it.

It's my 1st ever Blender plugin. Anyway you can also run it by going to the "Scripts" Workspace and load / run importldd.py.

Then you will be present with an import dialogue. It should auto-detect your db.lif (or extracted db folder) - you can see at the upper right.

Let me know your success rate :wink: or of course any potential errors.

As I'm a little occupied with work recently I unfortunately didn't have time to focus on this as much as I would like. For example lack of importing of decals info is what is bugging myself.

Cheers !

 

Firstly, thanks again for your reply to my query. Second, I received an error message that boils down to, <DOCTYPE html> File "\importldd.py", line 7 Python script failed, check the message in the system console.

See photos below.

50806045786_d8d891317a_z.jpg

50806045906_4aedd6444b_z.jpg

Share this post


Link to post
Share on other sites
13 minutes ago, Jason C. Hand said:

Firstly, thanks again for your reply to my query. Second, I received an error message that boils down to, <DOCTYPE html> File "\importldd.py", line 7 Python script failed, check the message in the system console.

See photos below.

50806045786_d8d891317a_z.jpg

50806045906_4aedd6444b_z.jpg

Seem somehow the file saved was in HTML: Can you try to download this file ?

https://raw.githubusercontent.com/sttng/ImportLDD/main/importldd.py

Thanks again !

Edited by M2m

Share this post


Link to post
Share on other sites

hello i have this problem when i'm trying to activate the addon im using blender 3.0

Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender 3.0\3.0\scripts\modules\addon_utils.py", line 387, in enable
    mod.register()
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\ImportLDD-main\__init__.py", line 27, in register
    bpy.utils.register_class(ImportLDDOps)
NameError: name 'ImportLDDOps' is not defined

Share this post


Link to post
Share on other sites
On 6/16/2022 at 11:49 PM, Jason C. Hand said:

Hello @M2m,

I have run into some new trouble with the ImportLDD plugin for Blender. Screencap below for some elucidation:

 

https://flic.kr/p/2nsxrZE

I am using Blender 2.93.7. Any suggestions??

Never mind, got it to work now. Sorry for the mix-up. @andardbricksplease use this link. This should get ImportLDD to work: https://raw.githubusercontent.com/sttng/ImportLDD/main/importldd.py.

Hope this helps, friend.

Share this post


Link to post
Share on other sites
On 6/18/2022 at 9:21 PM, Jason C. Hand said:

Never mind, got it to work now. Sorry for the mix-up. @andardbricksplease use this link. This should get ImportLDD to work: https://raw.githubusercontent.com/sttng/ImportLDD/main/importldd.py.

Hope this helps, friend.

i'm using that version you suggested but i come up with this error now, i want to import this big head piece to blender

Python: Traceback (most recent call last):
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\importldd.py", line 1454, in execute
    return convertldd_data(context, self.filepath, self.lddLIFPath, self.useLogoStuds, self.useLDDCamera)
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\importldd.py", line 1394, in convertldd_data
    converter.Export(filename=filepath, useLogoStuds=useLogoStuds, useLDDCamera=useLDDCamera)  
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\importldd.py", line 989, in Export
    geo = Geometry(designID=pa.designID, database=self.database)
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\importldd.py", line 376, in __init__
    primitive = Primitive(data = database.filelist[os.path.normpath(PRIMITIVEPATH + designID + '.xml')].read())
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\importldd.py", line 502, in __init__
    self.comment = node[0].nodeValue
TypeError: 'Comment' object is not subscriptable

location: <unknown location>:-1

Screenshot (219)_11zon.jpg

Share this post


Link to post
Share on other sites

Hey @M2m, I am getting this error whenever I try to run it: 

"Traceback (most recent call last):
  File "\importldd.py", line 1455, in execute
  File "\importldd.py", line 1395, in convertldd_data
  File "\importldd.py", line 953, in Export
AttributeError: 'Converter' object has no attribute 'scene'

location: <unknown location>:-1"

I am using Blender 2.9.0 and am trying to run the script directly from the scripting tab. It will pull up a file selector and let me select a file but then it gives me that error. It also gives me the same error when I try to install it as an add-on. Any ideas?

Share this post


Link to post
Share on other sites
On 12/20/2022 at 1:44 AM, JGuy said:

Hey @M2m, I am getting this error whenever I try to run it: 

"Traceback (most recent call last):
  File "\importldd.py", line 1455, in execute
  File "\importldd.py", line 1395, in convertldd_data
  File "\importldd.py", line 953, in Export
AttributeError: 'Converter' object has no attribute 'scene'

location: <unknown location>:-1"

I am using Blender 2.9.0 and am trying to run the script directly from the scripting tab. It will pull up a file selector and let me select a file but then it gives me that error. It also gives me the same error when I try to install it as an add-on. Any ideas?

Are you on Windows or macOS or Linux ? In fact i don't maintain the plugin anymore. But I might check on your error.

Share this post


Link to post
Share on other sites
On 12/23/2022 at 6:24 AM, M2m said:

Are you on Windows or macOS or Linux ? In fact i don't maintain the plugin anymore. But I might check on your error.

With this specific error readout i was on Windows 11, but i’ve also tried it on macOS Monterey and gotten similar if not the same errors

Share this post


Link to post
Share on other sites

I'd say I'm really interested in LDD to Blender converter, but I don't think it's usable for me in the current state. I wish there was a way to recreate LDD2POV-Ray functionality for next-gen rendering...

Share this post


Link to post
Share on other sites
On 6/21/2022 at 1:16 AM, andardbricks said:

i'm using that version you suggested but i come up with this error now, i want to import this big head piece to blender

Python: Traceback (most recent call last):
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\importldd.py", line 1454, in execute
    return convertldd_data(context, self.filepath, self.lddLIFPath, self.useLogoStuds, self.useLDDCamera)
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\importldd.py", line 1394, in convertldd_data
    converter.Export(filename=filepath, useLogoStuds=useLogoStuds, useLDDCamera=useLDDCamera)  
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\importldd.py", line 989, in Export
    geo = Geometry(designID=pa.designID, database=self.database)
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\importldd.py", line 376, in __init__
    primitive = Primitive(data = database.filelist[os.path.normpath(PRIMITIVEPATH + designID + '.xml')].read())
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\importldd.py", line 502, in __init__
    self.comment = node[0].nodeValue
TypeError: 'Comment' object is not subscriptable

location: <unknown location>:-1

I also encountered this error, and I figured out it actually has to do with the piece itself rather than the plugin.

I ended up using the LDD part modifier to get a file of just the geometry, and put it into blender to find out the faces weren't actually attached to one another. Spent a while unifying all the vertices, but I managed to create a version that works.

Sadly, the file is too large to attach here, but hopefully my description is good enough to help you figure it out.

Share this post


Link to post
Share on other sites
On 6/21/2022 at 1:16 PM, andardbricks said:

i'm using that version you suggested but i come up with this error now, i want to import this big head piece to blender

Python: Traceback (most recent call last):
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\importldd.py", line 1454, in execute
    return convertldd_data(context, self.filepath, self.lddLIFPath, self.useLogoStuds, self.useLDDCamera)
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\importldd.py", line 1394, in convertldd_data
    converter.Export(filename=filepath, useLogoStuds=useLogoStuds, useLDDCamera=useLDDCamera)  
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\importldd.py", line 989, in Export
    geo = Geometry(designID=pa.designID, database=self.database)
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\importldd.py", line 376, in __init__
    primitive = Primitive(data = database.filelist[os.path.normpath(PRIMITIVEPATH + designID + '.xml')].read())
  File "C:\Users\ASUS\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\importldd.py", line 502, in __init__
    self.comment = node[0].nodeValue
TypeError: 'Comment' object is not subscriptable

location: <unknown location>:-1

Screenshot (219)_11zon.jpg

I got this part working. The issue was that this parts .xml file has a comment and the plugin didn't parse xml comments correctly.

Updated version here (and tested with Blender 3.4):

https://raw.githubusercontent.com/sttng/ImportLDD/main/importldd.py

You have to un-install the plugin 1st, afterwards restart blender, then install again.

Hope this fixed the issue.

On 12/20/2022 at 1:44 AM, JGuy said:

Hey @M2m, I am getting this error whenever I try to run it: 

"Traceback (most recent call last):
  File "\importldd.py", line 1455, in execute
  File "\importldd.py", line 1395, in convertldd_data
  File "\importldd.py", line 953, in Export
AttributeError: 'Converter' object has no attribute 'scene'

location: <unknown location>:-1"

I am using Blender 2.9.0 and am trying to run the script directly from the scripting tab. It will pull up a file selector and let me select a file but then it gives me that error. It also gives me the same error when I try to install it as an add-on. Any ideas?

Maybe you can send the LDD file so I can check ?

Share this post


Link to post
Share on other sites

Hello!

First of all, THANK YOU FOR MAKING THIS! I've been searching for days for a way to finally render my LDD mocs with the modded parts, and your plugin (mostly)  works like an absolute charm for that! Compared to bluerender, which doesn't accept the new lif file that LIFCreator gives me, or importing into Stud.io, which rotates half the pieces wrong, your plugin is definitely the best option for me right now.

That being said, I have been getting a few smaller issues with some of my complex models.

First of all, it seems that the plugin doesn't like decorated bricks a lot. When I try to import something with a brick that has a print on it, i get the following error:

Python: Traceback (most recent call last):
  File "C:\Users\[my name]\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\importldd.py", line 1454, in execute
    return convertldd_data(context, self.filepath, self.lddLIFPath, self.useLogoStuds, self.useLDDCamera)
  File "C:\Users\[my name]\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\importldd.py", line 1394, in convertldd_data
    converter.Export(filename=filepath, useLogoStuds=useLogoStuds, useLDDCamera=useLDDCamera)  
  File "C:\Users\[my name]\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\importldd.py", line 1144, in Export
    texImage.image = bpy.data.images.load(os.path.normpath(decofilename))
RuntimeError: Error: Cannot read '\Decorations\101321.png': No such file or directory

It will then stop importing, so I'll have only half a model or nothing at all in blender. If I go back into LDD and remove the decoration from the part, the model is imported without issue. Apparently it just can't find the decoration files, I've tried it with both the new and old decorations, same issue.

Second of all, on some models, some brick faces will show up pink when imported. I'll attach a screenshot. I have no idea why this happens, but at least it seems to be constistent per brick: the sand-yellow 1x1 bricks in the screenshot all consistently have 3 pink faces (some of them are just rotated apparently).

The import doesn't throw any errors for this issue.

I'm sorry about the shoddy screenshot compression. I would love to attach more screenshots, but I'm only allowed a max total size of 0.1mb, which isn't enough for much of anything if we're honest (does this get better if I post more? This is my first forum contribution after all).

I can also send you some of my "incriminating" model files if you want, just tell me through which channel you'd like to receive them. Be aware that I do use the new modded LDD parts from the key topic on here, though I think I can also find some with just the "vanilla" parts.

Screenshot 2024-03-04 160243.png

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.