From 100ed60f2ddc6cd54516932f96538e87654e504d Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Wed, 9 Jul 2025 09:44:10 +0200 Subject: [PATCH] Fix: Importer can fail with blender file browser recursive option enabled The files property, provided by the blender file browser, contain paths relative to the directory property. Use that instead of using the filepath parent directory. --- scripts/addons_core/io_scene_gltf2/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/addons_core/io_scene_gltf2/__init__.py b/scripts/addons_core/io_scene_gltf2/__init__.py index c809ccb3892..162ecdb8bac 100755 --- a/scripts/addons_core/io_scene_gltf2/__init__.py +++ b/scripts/addons_core/io_scene_gltf2/__init__.py @@ -5,7 +5,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": (4, 5, 46), + "version": (4, 5, 47), 'blender': (4, 4, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', @@ -1851,6 +1851,11 @@ class ImportGLTF2(Operator, ConvertGLTF2_Base, ImportHelper): filter_glob: StringProperty(default="*.glb;*.gltf", options={'HIDDEN'}) + directory: StringProperty( + subtype='DIR_PATH', + options={'HIDDEN', 'SKIP_PRESET'}, + ) + files: CollectionProperty( name="File Path", type=bpy.types.OperatorFileListElement, @@ -2028,9 +2033,8 @@ class ImportGLTF2(Operator, ConvertGLTF2_Base, ImportHelper): if self.files: # Multiple file import ret = {'CANCELLED'} - dirname = os.path.dirname(self.filepath) for file in self.files: - path = os.path.join(dirname, file.name) + path = os.path.join(self.directory, file.name) if self.unit_import(path, import_settings) == {'FINISHED'}: ret = {'FINISHED'} return ret