import itertools
class DataExporter:
- def __init__(self):
- self.collection = False
- self.shared_resources = True
-
- def export_to_file(self, context, out_fn):
+ def export_to_file(self, context, out_fn, *, collection=False, shared_resources=False):
from .util import Progress
progress = Progress(context)
base, ext = os.path.splitext(base)
refs = dummy_res.collect_references()
- if not self.shared_resources:
+ if not shared_resources:
numbers = {}
for r in refs:
res_ext = os.path.splitext(r.name)[1]
r.name = base+res_ext
numbers[res_ext] = n+1
- if self.collection:
+ if collection:
dummy_res.write_collection(out_fn, exclude_self=True)
else:
for r in refs:
if s.camera:
all_objects.append(s.camera)
+ scene_queue = list(scenes.values())
+ ordered_scenes = []
+ while scene_queue:
+ s = scene_queue.pop(0)
+ if not s.background_set or s.background_set in ordered_scenes:
+ ordered_scenes.append(s)
+ else:
+ scene_queue.append(s)
+
from .util import make_unique
all_objects = make_unique(all_objects)
resources = {}
dummy_res = data_exporter.export_resources(context, all_objects, resources, None, progress)
- for s in scenes.values():
+ for s in ordered_scenes:
scene_name = s.name+".scene"
if scene_name not in resources:
scene_res = scene_exporter.export_scene(s, resources)