diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2019-10-12 18:02:14 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2019-10-12 18:02:43 +0300 |
commit | 67e42c79e5c3f2724d33b7dc2f0fb4ab84d10e7f (patch) | |
tree | 2107b8382aed4c3e668350e4f1d39042e6e8573c /io_scene_gltf2 | |
parent | 171c4520fe007e453d43fb24019be7dfd277a065 (diff) |
glTF importer: multiple files import feature
Diffstat (limited to 'io_scene_gltf2')
-rwxr-xr-x | io_scene_gltf2/__init__.py | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index 36fda5ce..48574ef4 100755 --- a/io_scene_gltf2/__init__.py +++ b/io_scene_gltf2/__init__.py @@ -15,7 +15,7 @@ bl_info = { 'name': 'glTF 2.0 format', 'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', - "version": (1, 0, 4), + "version": (1, 0, 5), 'blender': (2, 81, 6), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', @@ -57,7 +57,8 @@ import bpy from bpy.props import (StringProperty, BoolProperty, EnumProperty, - IntProperty) + IntProperty, + CollectionProperty) from bpy.types import Operator from bpy_extras.io_utils import ImportHelper, ExportHelper @@ -730,6 +731,11 @@ class ImportGLTF2(Operator, ImportHelper): filter_glob: StringProperty(default="*.glb;*.gltf", options={'HIDDEN'}) + files: CollectionProperty( + name="File Path", + type=bpy.types.OperatorFileListElement, + ) + loglevel: IntProperty( name='Log Level', description="Log Level") @@ -758,14 +764,30 @@ class ImportGLTF2(Operator, ImportHelper): return self.import_gltf2(context) def import_gltf2(self, context): - import time - from .io.imp.gltf2_io_gltf import glTFImporter - from .blender.imp.gltf2_blender_gltf import BlenderGlTF + import os self.set_debug_log() import_settings = self.as_keywords() - self.gltf_importer = glTFImporter(self.filepath, import_settings) + 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) + if self.unit_import(path, import_settings) == {'FINISHED'}: + ret = {'FINISHED'} + return ret + else: + # Single file import + return self.unit_import(self.filepath, import_settings) + + def unit_import(self, filename, import_settings): + import time + from .io.imp.gltf2_io_gltf import glTFImporter + from .blender.imp.gltf2_blender_gltf import BlenderGlTF + + self.gltf_importer = glTFImporter(filename, import_settings) success, txt = self.gltf_importer.read() if not success: self.report({'ERROR'}, txt) |