TobyLobster / ImportLDraw

A Blender plug-in for importing LDraw file format Lego models and parts.
GNU General Public License v2.0
278 stars 48 forks source link

Intermittent Python errors when importing a model #86

Closed VanessaE closed 10 months ago

VanessaE commented 1 year ago

This is Blender 3.4.0 on Debian Bullseye, using v1.1.18 of your importer and starting from a clean/empty project with each try.

When I go to import basically *any* part, the part itself is imported okay, but then Blender throws some Python errors that don't make any sense to me. In "realistic look" mode:

Python: Traceback (most recent call last):
  File "/home/vanessa/.config/blender/3.4/scripts/addons/io_scene_importldraw/importldraw.py", line 399, in execute
    loadldraw.loadFromFile(self, self.filepath)
  File "/home/vanessa/.config/blender/3.4/scripts/addons/io_scene_importldraw/loadldraw/loadldraw.py", line 4610, in loadFromFile
    setupRealisticLook()
  File "/home/vanessa/.config/blender/3.4/scripts/addons/io_scene_importldraw/loadldraw/loadldraw.py", line 3936, in setupRealisticLook
    render.alpha_mode = 'SKY'
AttributeError: 'RenderSettings' object has no attribute 'alpha_mode'

If I switch to "instructions look", I get:

Python: Traceback (most recent call last):
  File "/home/vanessa/.config/blender/3.4/scripts/addons/io_scene_importldraw/importldraw.py", line 399, in execute
    loadldraw.loadFromFile(self, self.filepath)
  File "/home/vanessa/.config/blender/3.4/scripts/addons/io_scene_importldraw/loadldraw/loadldraw.py", line 4608, in loadFromFile
    setupInstructionsLook()
  File "/home/vanessa/.config/blender/3.4/scripts/addons/io_scene_importldraw/loadldraw/loadldraw.py", line 4166, in setupInstructionsLook
    composite = scene.node_tree.nodes["Composite"]
KeyError: 'bpy_prop_collection[key]: key "Composite" not found'

There are other issues also: if I use "original Ldraw colours" mode, the model is imported with a random rotation about the X axis. In all cases, I also end up with several color-related "Collections" I didn't ask for, even when the tree is set to "flatten", which aren't useful in my particular situation.

The strange thing is while composing this issue, suddenly the importer stopped throwing errors, the extra collections stopped appearing, and the random rotation went away, even though I'm importing the same model each time (merely because I know the part number), and I've been restarting Blender with each try also. I can't begin to explain that. Maybe the importer found some magic bit it needed and cached it?

My settings when it was throwing errors:

image

My settings now are identical, apart from turning off "curved wall normals" (which has no impact on or off).

Blend file with a single part imported with those settings: 47224c01.blend.zip

Oh and yes I know that scale seems crazy high, but I use these models as "visual aids" in my 3d printable bricks project. The scale in those project files is set to 10 so that the models export to their proper real-life size (with the STL exporter set to a scale of 1), so the LDraw import needs a crazy-high setting to match.

TobyLobster commented 10 months ago

I have just released a new version that may fix these issues.