self.visible_only = True
self.collection = True
self.skip_existing = True
- self.show_progress = True
def export_to_file(self, context, out_fn):
+ from .util import Progress
+ progress = Progress(context)
+
from .scene import create_scene_from_current
scene = create_scene_from_current(context, selected_only=self.selected_only, visible_only=self.visible_only)
+ resources = {}
+ self.export_scene_resources(context, scene, resources, progress)
+ 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)
- from .util import Progress
- progress = Progress(self.show_progress and context)
-
- from .export import DataExporter
- data_exporter = DataExporter()
-
- resources = {}
- data_exporter.export_resources(context, scene.prototypes, resources, None, progress)
- scene_res = self.export_scene(scene, resources, progress)
- refs = scene_res.collect_references()
-
if self.collection:
existing = None
if self.skip_existing:
scene_res.write_collection(out_fn, filter=existing)
else:
scene_res.write_to_file(out_fn)
- for r in refs:
+ for r in scene_res.collect_references():
r.write_to_file(os.path.join(path, r.name))
- def export_scene(self, scene, resources, progress):
+ def export_scene_resources(self, context, scene, resources, progress):
+ from .export import DataExporter
+ data_exporter = DataExporter()
+
+ data_exporter.export_resources(context, scene.prototypes, resources, None, progress)
+
+ def export_scene(self, scene, resources):
from .datafile import Resource, Statement, Token
scene_res = Resource(scene.name+".scene", "scene")
st.sub.append(ss)
scene_res.statements.append(st)
- progress.set_progress(1.0)
-
return scene_res