5 self.show_progress = True
6 self.collection = False
7 self.shared_resources = True
9 def export_to_file(self, context, out_fn):
10 from .util import Progress
11 progress = Progress(self.show_progress and context)
13 objects = context.selected_objects
18 dummy_res = self.export_resources(context, objects, resources, material_atlases, progress)
20 path, base = os.path.split(out_fn)
21 base, ext = os.path.splitext(base)
23 refs = dummy_res.collect_references()
24 if not self.shared_resources:
27 res_ext = os.path.splitext(r.name)[1]
28 n = numbers.get(res_ext, 0)
30 r.name = "{}_{}{}".format(base, n, res_ext)
33 numbers[res_ext] = n+1
36 dummy_res.write_collection(out_fn, exclude_self=True)
39 r.write_to_file(os.path.join(path, r.name))
41 def export_resources(self, context, objects, resources, material_atlases, progress):
42 if material_atlases is None:
45 object_exporter = None
46 camera_exporter = None
47 armature_exporter = None
49 from .datafile import Resource
50 dummy_res = Resource("dummy", "dummy")
52 for i, obj in enumerate(objects):
53 progress.push_task_slice(obj.name, i, len(objects))
56 if not object_exporter:
57 from .export_object import ObjectExporter
58 object_exporter = ObjectExporter()
59 object_exporter.export_object_resources(context, obj, resources, material_atlases, progress)
60 res = object_exporter.export_object(obj, resources, progress)
61 elif obj.type=='CAMERA':
62 if not camera_exporter:
63 from .export_camera import CameraExporter
64 camera_exporter = CameraExporter()
65 res = camera_exporter.export_camera(obj)
66 elif obj.type=='ARMATURE':
67 if not armature_exporter:
68 from .export_armature import ArmatureExporter
69 armature_exporter = ArmatureExporter()
70 res = armature_exporter.export_armature(context, obj)
73 resources[res.name] = res
74 dummy_res.create_reference_statement("ref", res)