[Bf-extensions-cvs] [b294d4c7] master: glTF importer: fix when glTF file has no scene

Julien Duroure noreply at git.blender.org
Sun Apr 3 10:23:25 CEST 2022


Commit: b294d4c7665469643b428950b189541699980cfe
Author: Julien Duroure
Date:   Sun Apr 3 10:18:34 2022 +0200
Branches: master
https://developer.blender.org/rBAb294d4c7665469643b428950b189541699980cfe

glTF importer: fix when glTF file has no scene

===================================================================

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/imp/gltf2_blender_scene.py

===================================================================

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index c844838b..ec6ac40a 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -4,7 +4,7 @@
 bl_info = {
     'name': 'glTF 2.0 format',
     'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
-    "version": (3, 2, 22),
+    "version": (3, 2, 23),
     'blender': (3, 1, 0),
     'location': 'File > Import-Export',
     'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_scene.py b/io_scene_gltf2/blender/imp/gltf2_blender_scene.py
index 2092a6be..672b68c8 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_scene.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_scene.py
@@ -36,12 +36,18 @@ class BlenderScene():
         BlenderNode.create_vnode(gltf, 'root')
 
         # User extensions before scene creation
-        import_user_extensions('gather_import_scene_after_nodes_hook', gltf, gltf.data.scenes[gltf.data.scene], scene)
+        gltf_scene = None
+        if gltf.data.scene is not None:
+            gltf_scene = gltf.data.scenes[gltf.data.scene]
+        import_user_extensions('gather_import_scene_after_nodes_hook', gltf, gltf_scene, scene)
 
-        # User extensions after scene creation
         BlenderScene.create_animations(gltf)
 
-        import_user_extensions('gather_import_scene_after_animation_hook', gltf, gltf.data.scenes[gltf.data.scene], scene)
+        # User extensions after scene creation
+        gltf_scene = None
+        if gltf.data.scene is not None:
+            gltf_scene = gltf.data.scenes[gltf.data.scene]
+        import_user_extensions('gather_import_scene_after_animation_hook', gltf, gltf_scene, scene)
 
         if bpy.context.mode != 'OBJECT':
             bpy.ops.object.mode_set(mode='OBJECT')



More information about the Bf-extensions-cvs mailing list