]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/export_scene.py
Redesign progress and error reporting in the Blender exporter
[libs/gl.git] / blender / io_mspgl / export_scene.py
index a069af2a60d6fafa88313705e6b743a43267320d..78ce2cbd5a69b2329337e72e5ae499b8c9dc513e 100644 (file)
@@ -4,21 +4,21 @@ import itertools
 import mathutils
 
 class SceneExporter:
-       def export_to_file(self, context, out_fn, *, selected_only=False, visible_only=True, collection=True, skip_existing=True):
-               from .util import Progress
-               progress = Progress(context)
-
+       def export_to_file(self, ctx, out_fn, *, selected_only=False, visible_only=True, collection=True, skip_existing=True):
                from .scene import create_scene_from_current
-               scene = create_scene_from_current(context, selected_only=selected_only, visible_only=visible_only)
+               task = ctx.task("Preparing scene", 0.1)
+               scene = create_scene_from_current(task, selected_only=selected_only, visible_only=visible_only)
 
                resources = {}
-               self.export_scene_resources(context, scene, resources, progress)
+               task = ctx.task("Exporting resources", 0.9)
+               self.export_scene_resources(task, scene, resources)
+               task = ctx.task(scene, 1.0)
                scene_res = self.export_scene(scene, resources)
-               progress.set_progress(1.0)
 
                path, base = os.path.split(out_fn)
                base, ext = os.path.splitext(base)
 
+               task = ctx.task("Writing files", 1.0)
                if collection:
                        existing = None
                        if skip_existing:
@@ -29,11 +29,11 @@ class SceneExporter:
                        for r in scene_res.collect_references():
                                r.write_to_file(os.path.join(path, r.name))
 
-       def export_scene_resources(self, context, scene, resources, progress):
+       def export_scene_resources(self, ctx, scene, resources):
                from .export import DataExporter
                data_exporter = DataExporter()
 
-               data_exporter.export_resources(context, scene.prototypes, resources, None, progress)
+               data_exporter.export_resources(ctx, scene.prototypes, resources, None)
 
        def export_scene(self, scene, resources):
                from .datafile import Resource, Statement, Token