Sarah-C / BlenderImportLDD

Blender Lego Digital Designer importer.
MIT License
1 stars 1 forks source link

Python errors using blender 4.0 and 4.1 #1

Open Jackpedleham opened 4 months ago

Jackpedleham commented 4 months ago

On import i get this:

Traceback (most recent call last):
  File "C:\Users\Jack\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\BlenderImportLDD.py", line 1481, in execute
    return convertldd_data(context, self.filepath, self.lddLIFPath, self.useLogoStuds, self.useLDDCamera)
  File "C:\Users\Jack\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\BlenderImportLDD.py", line 1416, in convertldd_data
    converter.Export(filename=filepath, useLogoStuds=useLogoStuds, useLDDCamera=useLDDCamera)
  File "C:\Users\Jack\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\BlenderImportLDD.py", line 955, in Export
    total = len(self.scene.Bricks)
AttributeError: 'Converter' object has no attribute 'scene'
Sarah-C commented 4 months ago

Ballz, no one else has had that error yet - from the looks of the error things have been moved around in the object tree. What's going to be fun is getting the fix to work in V4, and keeping the code the same for Blender version 3.x. I think there's some blender version variables I can put in IF conditions.

I'm new to python and these plugins, so it'll be a learning exercise for me. I'm on it though! I'll start looking Saturday morning over my red-bull.

Thanks for letting me know of the issue!

Jackpedleham commented 4 months ago

Ballz, no one else has had that error yet - from the looks of the error things have been moved around in the object tree. What's going to be fun is getting the fix to work in V4, and keeping the code the same for Blender version 3.x. I think there's some blender version variables I can put in IF conditions.

I'm new to python and these plugins, so it'll be a learning exercise for me. I'm on it though! I'll start looking Saturday morning over my red-bull.

Thanks for letting me know of the issue!

Interestingly enough i get this error with the old importer too. Perhaps its the specific files im using. Ill try some others!

EDIT: Nope i tried with a model i build in studio and exported to LFXML and the same error happened. Which version of blender do you have it working correctly in? Ive just tried with 4.1, 4.0 and 3.6 and i get the same error even with the stud.io lxfml export.

Sarah-C commented 4 months ago

Hm. I'm thinking the Python is assuming there's always a scene there.

In my Blender there's a default scene when I first open it, similar to the default cube but with a Plane instead.

I've just tried deleting the collection, but the stuff still imports! Could you try adding the below basic scene? Just to test. Perhaps the code needs to check for a "Scene" object and add one if there isn't!

Scene Collection ---Collection ------Camera ------Light ------Plane

Also, you could send me the smallest LFX/LFXML file you've got? (Ah, LFXML is inside the LXF which is a renamed ZIP file!)

Sarah-C commented 4 months ago

Oh yes, it works definitely on 3.6.1 I just double checked my sub-version number. This issue's weeeeird.

Thinking about it more..... perhaps it's not that there's no "Scene" object yet in Blender, but that the "Converter" object for some reason hasn't inherited the "scene" object that it sticks parts in. The correct Python version is in Blender, so it can't be out of sync....

This language is a bit like C#, but the API's entirely unique, and the way these objects move around and come in and out of scope.

AttributeError: 'Converter' object has no attribute 'scene'

Of course, in the meantime if there were just 1 or two models you wanted, I could load them into Blender and then send them back to you? =D

Sarah-C commented 4 months ago

I've made a tinnnnny change to the code, can you delete the plugin and then reinstall it please?

It tries importing just after the plugin is registered, which isn't allowed. It may have been knocking the code out.

Sarah-C commented 4 months ago

The good news is, if we get it working in your Blender, it works on 4.1 as well! (I tested it on my PC, and it imports fine)

What's the best way to send you an LXF file?

Sarah-C commented 4 months ago

I've asked on Reddit! https://www.reddit.com/r/blenderpython/comments/1cv0wda/ive_got_a_free_plugin_user_getting_attributeerror/

Jackpedleham commented 4 months ago

So, My blender file DOES have the default scene. So i dont imagine thats the issue. I will try the reinstall and get back to you. Hopefully someone on reddit knows the cause of that error!

Cornerback24 commented 4 months ago

I've asked on Reddit! https://www.reddit.com/r/blenderpython/comments/1cv0wda/ive_got_a_free_plugin_user_getting_attributeerror/

Hey, I saw your question on reddit and after downloading Lego Digital Designer, I found that at least in my case, for some reason if Lego Digital Designer was open during import it could cause that error (not all the time though, not sure quite what's going on there). Then it also failed for me on finding the localized strings file. I made a pull request with some changes I made to make the error reporting better and to make it work on my machine. Do whatever you want with it.

Jackpedleham commented 4 months ago

Unfortunately i get the same error with the new version @Sarah-C . I tried @Cornerback24 edit and got a slightly different error but still very similar.