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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user