bestdani / msfs2blend

Import Microsoft Flight Simulator (FS2020) Models in Blender
Apache License 2.0
143 stars 20 forks source link

Cannot import the A32NX #27

Open imagitama opened 1 year ago

imagitama commented 1 year ago

Tried importing best LOD of the cockpit of the A32NX from FlyByWire (A320_NEO_INTERIOR_LOD00.gltf) and I get this error:

Traceback (most recent call last):
  File "C:\Users\\AppData\Roaming\Blender Foundation\Blender\2.83\scripts\addons\io_msfs_gltf (1).py", line 760, in execute
    ImportProperties.convert_textures_dirs)
  File "C:\Users\\AppData\Roaming\Blender Foundation\Blender\2.83\scripts\addons\io_msfs_gltf (1).py", line 629, in import_msfs_gltf
    objects = create_objects(gltf['nodes'], meshes)
  File "C:\Users\\AppData\Roaming\Blender Foundation\Blender\2.83\scripts\addons\io_msfs_gltf (1).py", line 242, in create_objects
    mesh = meshes[node['mesh']]
TypeError: list indices must be integers or slices, not NoneType

location: <unknown location>:-1

Tested in Blender 3.1.2, 2.9 and 2.8.

The other LODs and exterior meshes import correctly.

imagitama commented 1 year ago

Fixed by catching all exceptions and just creating a new mesh:

def create_objects(nodes, meshes):
    objects = []
    for node in nodes:
        name = node['name']
        print(node)
        try:
            mesh = meshes[node['mesh']]
-        except KeyError:
+        except:
            mesh = bpy.data.meshes.new(name)

        obj = bpy.data.objects.new(name, mesh)